Posts

Showing posts with the label Radio Button

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.

Bootstrap Radio Button "checked" Flag

Answer : Assuming you want a default button checked. <div class="row"> <h1>Radio Group #2</h1> <label for="year" class="control-label input-group">Year</label> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" name="year" value="2011">2011 </label> <label class="btn btn-default"> <input type="radio" name="year" value="2012">2012 </label> <label class="btn btn-default active"> <input type="radio" name="year" value="2013" checked="">2013 </label> </div> </div> Add the active class to the button ( label tag) you want defaulted and checked="" to ...