Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unselect group of radio buttons using jQuery

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?

like image 963
Carl Avatar asked Aug 12 '11 17:08

Carl


People also ask

How do I uncheck all radio buttons?

If you want to uncheck all the radio buttons and checkboxes you will need to add one single line (in bold): $('#clear-all').

How can I uncheck checked radio button in jQuery?

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.

Can you uncheck radio buttons?

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.


1 Answers

As of jQuery 1.6, $("radio").prop("checked", false); is the suggested method.

like image 152
Dave Kiss Avatar answered Oct 05 '22 00:10

Dave Kiss