jquery Read check box value

Source: Internet
Author: User

<!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>

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.