Home > Web Front-end > JS Tutorial > body text

Implementation ideas for selecting all and unselecting all check boxes_javascript skills

WBOY
Release: 2016-05-16 17:25:23
Original
1011 people have browsed it
复制代码 代码如下:




复选框处理.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>



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!