Friday, June 25, 2010

Unchecking a html radio button

Given the following code,

 

<input type="radio" value="PG" name="courseType" /> Post Graduate </input>

<input type="radio" value="UG" name="courseType" /> Under Graduate </input>

 

To check the "PG" html radio button in jQuery:

 

jQuery(blahBlahBlah).attr('checked', 'true');

 

To uncheck it:

 

jQuery(blahBlahBlah).removeAttr('checked');

 

Note: the following will **NOT WORK**

 

jQuery(blahBlahBlah).attr('checked', 'false');

jQuery(blahBlahBlah).attr('checked', '');

No comments: