Home  >  Article  >  Web Front-end  >  jquery array storage checkbox all selected value sample code_jquery

jquery array storage checkbox all selected value sample code_jquery

WBOY
WBOYOriginal
2016-05-16 17:08:02999browse
Copy code The code is as follows:

Select all/unselect all
1
2
3
4


<script> <br>$("#chekcAll").click(function(){ <br>if(this.checked){ <br>$("input[name =items]").attr("checked","checked"); <br>} <br>else{ <br>$("input[name=items]").attr("checked",null); <br>} <br>}) <br>function show(){ <br>var strIds=new Array();//Declare an array to store ids<br>$("input[name=items]") .each(function (i,d){ <br>if (d.checked) { <br>strIds.push(d.value); <br>} <br>}) <br>if(strIds.length< 1) <BR>alert("You have no selected items!"); <BR>else{ <BR>var ids=strIds.join(","); <BR>alert("The strings you selected are:" ids); <BR>} <br><br><BR>} <br><br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn