input全选全不选

input全选全不选html

 

$(document).ready(function() {
index="";

$(".item").click(function(){
var checkAll=true;
var checkBoxList=$(".item");
for(var i=0;i<checkBoxList.length;i++){
if(!checkBoxList[i].checked){
checkAll=false;
break;
}
}
if(checkAll){
$(".checkAll").prop("checked",true);
}else{
$(".checkAll").prop("checked",false);
}
})
$(".checkAll").click(function(){
var checkBoxList=$(".item");
if(this.checked){
for(var i=0;i<checkBoxList.length;i++){
checkBoxList[i].checked=true;
// $(".diogoblack").show();
// $("#diogo-1").show();
}
}else{
for(var i=0;i<checkBoxList.length;i++){
checkBoxList[i].checked=false;
}
}
});

$(".page-up").click(function(){
$(".page-up").removeClass("hovergree");
$(this).addClass("hovergree");
})ui

});this

 

页面的htmlhtm

这里是控制全部input子项的html:rem

<input type="checkbox" value=1 class="checkAll  duig2" id="all" />input

这里是全部小的input:it

<input type="checkbox" name="" class="item duig"/>io

就这样写上就好function

 

写的不是很详细,你们能够借鉴一下class

相关文章
相关标签/搜索