Html实现多选,同时可以将选中的取消,代码如下:
<input name="check1" type="checkbox" value="check1"><input name="check2" type="checkbox" value="check2">
<input name="check3" type="checkbox" value="check3">
<input name="check4" type="checkbox" value="check4">
<input name="check5" type="checkbox" value="check5">
希望能帮到你
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
</head>
<body>
<input type="checkbox" checked>
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<button id="btn" onclick="qx()">全选</button>
<button id="btn1" onclick="qxqx()">取消全选</button>
<script>
var objs = document.getElementsByTagName('input')
console.log(objs)
function qx(){
for(var i = objs.length-1i>=0i--){
objs[i].checked = true
}
}
function qxqx(){
for(var i = objs.length-1i>=0i--){
objs[i].checked = false
}
}
</script>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)