jquery Gets the value of the Selected checkbox check box

Source: Internet
Author: User

jquery Gets the value of the Selected checkbox check box:
The checkbox check box is one of the commonly used form elements, and since it is used, it is generally necessary to get the value of the check box selected, and here's how to do this with jquery.
The code example is as follows:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Gets the value of the check box-ant tribe</title> <Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script> <Scripttype= "Text/javascript">$ (document). Ready (function() {Chk_value=""; $("[type=checkbox][checked]"). each (function() {Chk_value=Chk_value+$( This). Val ()+","  })  $("#bt"). Click (function() {alert (chk_value); })}) </Script> </Head> <Body> <form><inputtype= "checkbox"name= "CK"checked Value= "1">Ant Tribe one<inputtype= "checkbox"name= "CK"value= "2">Ant Tribe two<inputtype= "checkbox"name= "CK"checked Value= "3">Ant Tribe three<inputtype= "checkbox"name= "CK"value= "4">Ant Tribe four<inputtype= "checkbox"name= "CK"checked Value= "5">Ant Tribe Five<inputtype= "checkbox"name= "CK"value= "6">Ant Tribe six<inputtype= "button"ID= "BT"value= "View Results" /></form></Body> </HTML>

The above code implements our needs, click the button to pop-up the check box to select the Value property values.
Related reading:
1.[type=checkbox] Refer to the [Attribute=value] selector section of jquery .
The 2.each () function can refer to the each () method section of jquery .
The 3.val () function can be found in the section of the Val () method of jquery .

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=10362

For more information, refer to: http://www.softwhy.com/jquery/

jquery Gets the value of the Selected checkbox check box

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.