First, set the selection method
Copy Code code as follows:
$ ("Input[name= ' name ']"). Get (0). Checked=true;
$ ("Input[name= ' name ']"). attr (' checked ', ' true ');
$ ("Input[name= ' name ']:eq (0)"). attr ("Checked", ' checked ');
$ ("Input[name= ' Radio_name '][checked]"). Val (); Gets the value of the selected radio
Two, set check and uncheck sample
Copy Code code as follows:
<input type= "Radio" value= "0" name= "Jizai" id= "0"/> No
<input type= "Radio" value= "1" name= "Jizai" id= "1"/> is
#jquery中, the radio is set in this way.
$ ("#rdo1"). attr ("Checked", "checked");
$ ("#rdo1"). Removeattr ("checked");
By name
Copy Code code as follows:
$ ("input:radio[name=" Analyfsftype "]"). EQ (0). attr ("Checked", ' checked ');
$ ("input:radio[name=" Analyshowtype "]"). attr ("checked", false);
by ID
Copy Code code as follows:
$ ("#tradeType0"). attr ("Checked", "checked");
$ ("#tradeType1"). attr ("checked", false);
Third, another set selection method
Copy Code code as follows:
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("input[@type =radio][name=sex][@value =1]"). attr ("Checked", true);
});
</script>
Your sex:
Copy Code code as follows:
<input type= "Radio" name= "Sex" value= "1" <s:if test= "user.sex==1" >checked</s:if>/> Male
<input type= "Radio" name= "Sex" value= "0" <s:if test= "user.sex==0" >checked</s:if>/>
Four, according to the value set radio selected
Copy Code code as follows:
$ ("Input[name= ' radio_name '][value= ' to select Radio value ']"). attr ("Checked", true); Set Radio as selected based on value values
V. Using the Prop method to manipulate the sample
Copy Code code as follows:
$ (' input '). Removeattr (' checked ');
$ (' # ' +id+ ' input '). EQ (0)). Prop (' checked ', false);
$ (' # ' +id+ ' input '). EQ (0)). Prop (' checked ', true);