This article illustrates the method of obtaining radio value in jquery and shares it for everyone's reference. Specifically as follows:
Radio Group Radio:
Copy Code code as follows:
$ ("input[@type =radio][@checked]"). Val ();
Radio Group Radio:
Copy Code code as follows:
$ ("input[@type =radio]"). attr ("Checked", ' 2 ');//Set value=2 item is currently selected
Gets the value of a set of radio selected items
Copy Code code as follows:
var item = $ (' input[@name =items][@checked] '). Val ();
Radio the second element of a radio group is the currently selected value
Copy Code code as follows:
$ (' input[@name =items] '). Get (1). Checked = True
The old version of jquery
Copy Code code as follows:
Var_name = $ ("input[@name = ' radio_name ']:checked"). Val ();
Later versions of jquery 1.3
Copy Code code as follows:
Var_name = $ ("input[name= ' Radio_name ']:checked"). Val ();
Get the jquery instance of the radio value:
Copy Code code 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 ();
}
}
<form name= "Form1" method= "Post" action= "" >
<p>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "RADIOGROUP1_0" >
Radio </label>
<br>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "Radiogroup1_1" >
Radio </label>
<br>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "Radiogroup1_2" >
Radio </label>
<br>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "Radiogroup1_3" >
Radio </label>
<br>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "Radiogroup1_4" >
Radio </label>
<br>
<label>
<input type= "Radio" name= "Radiogroup1" value= "Radio" id= "Radiogroup1_5" >
Radio </label>
<br>
</p>
</form>
I hope this article will help you with your JavaScript programming.