This article mainly introduces examples of getting radio values by jquery, and summarizes in detail various common methods for obtaining radio values by jQuery, for more information about how to obtain the radio value of jquery, see the following example. The details are as follows:
Radio Group radio:
The Code is as follows:
$ ("Input [@ type = radio] [@ checked]"). val ();
Radio Group radio:
The Code is as follows:
$ ("Input [@ type = radio]"). attr ("checked", '2'); // set the project with value = 2 to the selected one
Obtains the value of a set of radio selected items.
The Code is as follows:
Var item = $ ('input [@ name = items] [@ checked] '). val ();
The second element of the radio Group is the currently selected value.
The Code is as follows:
$ ('Input [@ name = items] '). get (1). checked = true
Old jquery version
The Code is as follows:
Var_name = $ ("input [@ name = 'Radio _ name']: checked"). val ();
Versions later than jquery 1.3
The Code is as follows:
Var_name = $ ("input [name = 'Radio _ name']: checked"). val ();
Jquery instance for obtaining the radio value:
The Code is as follows:
Function getra (){
Var_name = $ ("input [name = 'isspecialcnt ']: checked"). val ();
// Alert (var_name );
If (var_name = '1 '){
$ ("# Isspecialcntyes"). show ();
$ ("# Isspecialcntno"). hide ();
}
If (var_name = '0 '){
$ ("# Isspecialcntyes"). hide ();
$ ("# Isspecialcntno"). show ();
}
}
I hope this article will help you design javascript programs.