Home > Article > Web Front-end > How do I programmatically check a radio button in jQuery?
Checking Radio Buttons with jQuery
In jQuery, checking a radio button can be a bit tricky. Here are a few common approaches:
Using .attr()
For jQuery versions prior to 1.6, the following syntax will work:
$("#radio_1").attr('checked', 'checked');
Using .prop()
For jQuery versions 1.6 and above, use the updated syntax:
$("#radio_1").prop("checked", true);
Additional Tips:
Troubleshooting:
If the provided methods aren't working, double-check the following:
The above is the detailed content of How do I programmatically check a radio button in jQuery?. For more information, please follow other related articles on the PHP Chinese website!