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.