Javascript 使用筛选表的“全选”脚本
我正在使用脚本,并且我正在为我的复选框使用第一行中的所有脚本。但首先,当我筛选一个列时,这个脚本也选择了隐藏行的复选框Javascript 使用筛选表的“全选”脚本,javascript,jquery,checkbox,selectall,Javascript,Jquery,Checkbox,Selectall,我正在使用脚本,并且我正在为我的复选框使用第一行中的所有脚本。但首先,当我筛选一个列时,这个脚本也选择了隐藏行的复选框 $(document).ready(function(){ $('#select_all').on('click',function(){ if(this.checked){ $('.checkbox').each(function(){ this.checked = true; }); }else{
$(document).ready(function(){
$('#select_all').on('click',function(){
if(this.checked){
$('.checkbox').each(function(){
this.checked = true;
});
}else{
$('.checkbox').each(function(){
this.checked = false;
});
}
});
$('.checkbox').on('click',function(){
if($('.checkbox:checked').length == $('.checkbox').length){
$('#select_all').prop('checked',true);
}else{
$('#select_all').prop('checked',false);
}
});
});
感谢您的帮助。使用jQuery:visible选择器来省略已筛选的复选框
嗯。我的新密码:
$(document).ready(function(){
$('#select_all').on('click',function(){
if(this.checked){
$('.checkbox:visible').each(function(){
this.checked = true;
});
}else{
$('.checkbox:visible').each(function(){
this.checked = false;
});
}
});
$('.checkbox:visible').on('click',function(){
if($('.checkbox:checked').length == $('.checkbox:visible').length){
$('#select_all').prop('checked',true);
}else{
$('#select_all').prop('checked',false);
}
});
});
谢谢大家 您也可以共享相关的html代码吗?请尝试$。复选框:visible'@Malk,这非常有效。谢谢
$(document).ready(function(){
$('#select_all').on('click',function(){
if(this.checked){
$('.checkbox:visible').each(function(){
this.checked = true;
});
}else{
$('.checkbox:visible').each(function(){
this.checked = false;
});
}
});
$('.checkbox:visible').on('click',function(){
if($('.checkbox:checked').length == $('.checkbox:visible').length){
$('#select_all').prop('checked',true);
}else{
$('#select_all').prop('checked',false);
}
});
});