<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>jquery Read check box value </title>
<body>
Str= "input[@name =opt" [@checked] ";
The value of alert ($ (str). val ());//($ (str). Val ()) is selected.
3. Reading all IDs is blank content:
Using a fuzzy query to read all IDs starts with blank
$ ("Input[id^=blank" + (i+1) + "]"). each (function () {
Alert ($ (this). Val ());
});
Four
$ ("input[type=checkbox][checked]"). each (function () {
Alert ($ (this). Val ());
})
If you use $ ("input[type=checkbox][checked]"). Val (), only the first selected value is returned
Instance
HTML code:
<form>
<input type= "checkbox" name= "Newsletter" checked= "checked" value= "daily"/>
<input type= "checkbox" name= "Newsletter" value= "Weekly"/>
<input type= "checkbox" name= "Newsletter" checked= "checked" value= "monthly"/>
</form>
jquery Code:
$ ("input:checked")
Using jquery to save the web effects of the judge checked or not, just a simple code can be taken out, specifically as follows:
Remove the selected value from the check box: $ ("input:checked"). each (function () {
var checktypevaluearr=$ (this). Val ();
Alert ("checktypevaluearr==" +checktypevaluearr);
});
To remove a value from a single check box:
$ (this). Val () or $ (' #checkid '). Val ();/body>