We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Document</title> </head> <body> <div> <button type="text">按钮</button> <button type="text">按钮</button> </div> <div> <ul> <li><input type="checkbox" id="all"><label for="all">全选</label></li> <li><input class="single" type="checkbox" id="single1"><label for="single1">单选</label></li> <li><input class="single" type="checkbox" id="single2"><label for="single2">单选</label></li> <li><input class="single" type="checkbox" id="single3"><label for="single3">单选</label></li> <li><input class="single" type="checkbox" id="single4"><label for="single4">单选</label></li> </ul> </div> <script type="text/javascript"> //获取绑定事件元素对象 var all = document.querySelector('#all'); var allSingle = document.querySelectorAll('.single'); var allSinglelen = allSingle.length; //全选操作 all.onchange = function(){ var mark = this.checked; for (var i = 0; i < allSinglelen; i++) { allSingle[i].checked = mark; }; }; //单选操作 复选框每次改变都要循环遍历所有复选框 for (var i = 0; i < allSinglelen; i++) { allSingle[i].onchange = function(){ for (var j = 0; j < allSinglelen; j++) { if(!allSingle[j].checked){ all.checked = false; break; }else{ all.checked = true; }; }; }; }; </script> </body> </html>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: