Check First Radio Button With JQuery


Answer :

If your buttons are grouped by their name attribute, try:

$("input:radio[name=groupName][disabled=false]:first").attr('checked', true); 

If they are grouped by a parent container, then:

$("#parentId input:radio[disabled=false]:first").attr('checked', true); 

$("input:radio[name=groupX]:not(:disabled):first") 

This should give you the first non-disabled radio-button from a group...


The below does what you want:

$(document).ready(   function(){     $('input:radio:first-child').attr('checked',true);   }   ); 

Demo at: JS Bin.


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?