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

相關文章
相關標籤/搜索