js全选反选
2021-03-25 16:27
标签:check round ++ doc java nbsp lse cti als js全选反选 标签:check round ++ doc java nbsp lse cti als 原文地址:https://www.cnblogs.com/qilin20/p/12655447.htmlDOCTYPE html>
html>
head>
meta charset="utf-8">
title>title>
head>
body>
div>
input type="checkbox" name="checkboxs" id="" value="咕咕" />咕咕br>
input type="checkbox" name="checkboxs" id="" value="嘎嘎" />嘎嘎br>
input type="checkbox" name="checkboxs" id="" value="嘟嘟" />嘟嘟br>
input type="button" id="quanxuan" value="全选" />
input type="button" id="quanbuxuan" value="全不选" />
input type="button" id="fanxuan" value="反选" />
div>
script type="text/javascript">
var checkboxs = document.getElementsByName("checkboxs");
document.getElementById("quanxuan").onclick=function(){
for(var i=0;icheckboxs.length;i++){
checkboxs[i].checked = true;
}
}
document.getElementById("quanbuxuan").onclick=function(){
for(var i=0;icheckboxs.length;i++){
checkboxs[i].checked = false;
}
}
document.getElementById("fanxuan").onclick=function(){
for(var i=0;icheckboxs.length;i++){
checkboxs[i].checked = !checkboxs[i].checked;
}
}
script>
body>
html>