Jquery radio operation code

Source: Internet
Author: User

// Set the second one to the selected status

// If (<% = rows ["sex"] % >== "2") {$ (': radio [name = sex]'). eq (1 ). attr ('checked', true );}

// Set the value to 2 as the selected status.
// If (<% = rows ["sex"]. toString () % >== '2') {$ ("input [name = 'sex']"). attr ("checked", '2 ');}


If (<% = rows ["sex"] % >== "2") {$ ("input [name = sex] [value = 2]"). attr ("checked", true );}

Today, I did something about NB. The above three conditions have all been tested to be of great significance. Is it because the local database has been operating remotely?

JQuery gets radio
Copy codeThe Code is 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>

Related Article

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.