Simple Jquery-js tutorial for radio operations

Source: Internet
Author: User
This article describes a simple example of Jquery radio operations. For more information, see. Jquery plugin tutorial
Jquery Learning
PHP Learning



In the preceding html code, you should be careful to find that the name attribute of three radio and the name attribute of one text are both "study"

The Code is as follows:


$ (Function (){
$ ('# Tijiao'). click (function (){
If ($ ("input: [name = study]: radio: checked"). length = 0 ){
Alert ("select the desired knowledge ");
Return false;
}
Var study = $ ("input: [name = study]: radio: checked"). val ();
Alert ("Thank you! You selected "+ study );
})
$ ("# Set_jqeury_study"). click (function (){
Var $ button = $ (this );
$ ("Input: [name = study]: radio"). each (function (){
If (this. value = $ button. attr ('title ')){
This. checked = true;
}
})
})
$ ("# View_input_text"). click (function (){
Alert ($ ("input [name = study]: text"). val ());
})
})


$ ("Input: [name = study]: radio: checked") This code obtains the jquery objects of all names whose attributes are "study" and have been selected by radio, by judging whether its length is equal to 0, you can know whether this radio option is selected. $ ("Input [name = study]: text") This code obtains the jquery object of the text input box whose name attribute is "study.
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.