How to check a radio button with jQuery? How to check a radio button with jQuery? javascript javascript

How to check a radio button with jQuery?


For versions of jQuery equal or above (>=) 1.6, use:

$("#radio_1").prop("checked", true);

For versions prior to (<) 1.6, use:

$("#radio_1").attr('checked', 'checked');

Tip: You may also want to call click() or change() on the radio button afterwards. See comments for more info.


Try this.

In this example, I'm targeting it with its input name and value

$("input[name=background][value='some value']").prop("checked",true);

Good to know: in case of multi-word value, it will work because of apostrophes, too.


One more function prop() that is added in jQuery 1.6, that serves the same purpose.

$("#radio_1").prop("checked", true);