Use jquery to get the value of the check box for the selected checkbox:
The checkbox is an important form element that is used in a number of multiple choices, and the following is an example of how to get the values of all the selected items in the check box, in order to bring some help to a friend who needs it.
The code is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript"> $(function(){ varTheArray=[]; $("#btn"). Click (function(){ $("input[name=ckb]:checked"). each (function() {Thearray.push ($ ( This). Val ()); }); alert (TheArray); })}) </Script></Head><Body><Div> <inputtype= "checkbox"name= "CKB"value= "Ant Tribe One"/>Ant Tribe one<inputtype= "checkbox"name= "CKB"value= "Ant Tribe II"/>Ant Tribe two<inputtype= "checkbox"name= "CKB"value= "Ant Tribe three"/>Ant Tribe three<inputtype= "button"ID= "BTN"value= "Take value"/></Div></Body></HTML>
The above code is very simple here is not more introduction, you can see the relevant reading.
Related reading:
The 1.click event can be found in the Click event section of jquery .
The 2.each () function can refer to the each () method section of jquery .
The 3.push () function can refer to the section of the push () method of the JavaScript array object .
The 4.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=12403
For more information, refer to: http://www.softwhy.com/jquery/
Use jquery to get the value of the check box for a selected checkbox