其他分享
首页 > 其他分享> > 全选全不选

全选全不选

作者:互联网

 <td><input type="checkbox" name="check" value="{$vo.id}">{$vo.id}</td>


<input type="button" class="yes" value="全選">
<input type="button" class="no" value="全不選">
<input type="button" class="yn" value="反選">

//全選
$(document).on("click",".yes",function () {
var check = document.getElementsByName("check");
for (i=0;i<check.length;i++){
if (check[i].checked==false){
check[i].checked = true;
}
}
})
//全不選
$(document).on("click",".no",function () {
var check = document.getElementsByName("check");
for (i=0;i<check.length;i++){
if (check[i].checked==true){
check[i].checked = false;
}
}
})
//反選
$(document).on("click",".yn",function () {
var check = document.getElementsByName("check");
for (i=0;i<check.length;i++){
if (check[i].checked==true){
check[i].checked = false;
}else {
check[i].checked = true;
}
}
})

标签:function,checked,全选,全不选,getElementsByName,document,true,check
来源: https://www.cnblogs.com/xuesensen/p/11159926.html