php - How to check the radio button by default -
here radio button.
<input type="radio" id="myradio" value=1> <input type="radio" id="myradio" value=2> <input type="radio" id="myradio" value=3>
in script want check third radio button
$('#myradio').attr('checked',true);
not checking radio button.
var target = '3';
how can check radio button id="myradio"
, value=3
?
concerning boolean attributes, consider dom element defined html markup , , assume in javascript variable named elem:
elem.checked true (boolean) change checkbox state $( elem ).prop( "checked" ) true (boolean) change checkbox state elem.getattribute( "checked" ) "checked" (string) initial state of checkbox; not change $( elem ).attr( "checked" ) (1.6) "checked" (string) initial state of checkbox; not change $( elem ).attr( "checked" ) (1.6.1+) "checked" (string) change checkbox state $( elem ).attr( "checked" ) (pre-1.6) true (boolean) changed checkbox state
correct:
<input type="radio" id="myradio3" value=3> $("myradio3").checked
it doesnt make sense if name 3 elements same id. rather should use classes.
Comments
Post a Comment