jQuery – Checking/Unchecking Radio Buttons

 

I recently had the need to check a certain Radio Button in a Radio Button Group. What I found out was pretty cool. With jQuery you can select the Radio Button Group by name an then select a single Button by it’s value.

Let’s say you have a form containing something like following:



 

and you want to

Check a Single Radio Button in the Group

$(„input[name=radioButtons][value=’yep‘]“).prop(„checked“,true);

 

Uncheck all Radio Buttons in the Group

$(„input[name=radioButtons]“).removeAttr(„checked“);

 

Pretty easy, isn’t it?