jquery Radio Operation Code _jquery

Source: Internet
Author: User
Set the second check state

if (<%=rows["Sex"]%>== "2") {$ (': Radio[name=sex] '). EQ (1). attr (' checked ', true);}

The design value=2 is selected
if (<%=rows["sex"]. ToString ()%>== ' 2 ') {$ ("input[name= ' sex ']"). attr ("Checked", ' 2 ');}


if (<%=rows["Sex"]%>== "2") {$ ("input[name=sex][value=2]"). attr ("Checked", true);

I did a NB thing today. All three of these conditions are tested and do not work because the local database has been operating at the remote database

JQuery gets Radio
Copy Code code as follows:

<div>
<input id= "Radio1" type= "Radio" Name= "Rad" value= "1" checked/>1
<input id= "Radio2" type= "Radio" Name= "Rad" value= "2"/>2
<input id= "Radio3" type= "Radio" Name= "Rad" value= "3"/>3
<input id= "Radio4" type= "Radio" Name= "Rad" value= "4"/>4
<input id= "Radio5" type= "Radio" Name= "Rad" value= "5"/>5
<input id= "Button1" type= "button" value= "button" onclick= "Return Button1_onclick ()"/>
<input id= "Button2" type= "button" value= "button" onclick= "Return Button2_onclick ()"/>
</div>

<script language= "javascript" type= "Text/javascript" >
<! [cdata[
function Button1_onclick () {
$ ("input"). each (function () {
if (This.type = = ' Radio ') {
Alert ($ (this). Val ());
}
});
}
function Button2_onclick () {
Alert ($ ("input[@type =radio]:checked"). Val ());
Alert ($ ("Input[name= ' rad ']:checked"). Val ());
Alert ($ ("input[@type =radio]"). Val ());
}
]]>
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.