Home  >  Article  >  Web Front-end  >  Implementation ideas for selecting all and unselecting all check boxes_javascript skills

Implementation ideas for selecting all and unselecting all check boxes_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:25:231008browse
复制代码 代码如下:




复选框处理.html






全选/全不选


爱好


看书


听音乐


打球


散步


写代码


<script> <br>window.onload = function(){ <br>var checkItem = document.getElementById("checkItem").onclick = function(){ <br>var itemsElement = document.getElementsByName("item"); <br>for (var i = 0; i < itemsElement.length; i ) { <BR>var itemElement = itemsElement[i]; <BR>if (this.checked) { <BR>itemElement.checked = "checked"; <BR>} <BR>else { <BR>itemElement.checked = null; <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