I'm using jQuery and I have a group of radio buttons all with the same name, but different value properties.
For example:
<input type = "radio" name = "thename" value="1"></input>
<input type = "radio" name = "thename" value="2"></input>
<input type = "radio" name = "thename" value="3"></input>
I want to make it so they are all unselected. Current state of my page has one of them clicked. How do I do this?
If you want to uncheck all the radio buttons and checkboxes you will need to add one single line (in bold): $('#clear-all').
Answer: Use the jQuery prop() method You can use the jQuery prop() method to check or uncheck radio button dynamically such as on click of button or an hyperlink etc. The prop() method require jQuery 1.6 and above.
To set a radio button to checked/unchecked, select the element and set its checked property to true or false , e.g. myRadio. checked = true . When set to true , the radio button becomes checked and all other radio buttons with the same name attribute become unchecked. Here is the HTML for the examples in this article.
As of jQuery 1.6, $("radio").prop("checked", false);
is the suggested method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With