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