Radio button checked by value

var value = 5;
$("input[name=mygroup][value=" + value + "]").attr('checked', 'checked');
Since jQuery 1.6, you can also use the .prop method with a boolean value (this should be the preferred method):$("input[name=mygroup][value=" + value + "]").prop('checked', true);$('input:radio[name="trainernames"][data-value="One"]').prop('checked',true);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store