//复选框
jQuery('#checkall').click(function(){
if (this.checked) {
$("input[name='box']:checkbox").each(function() {
$(this).prop("checked", true);
$(this).attr('vs','t1');
var v = $(this).attr('id');
var it = "#"+v+"";
$(this).attr('onclick',"btn_remove('"+it+"')");
});
} else {
$("input[name='box']:checkbox").each(function() {
$(this).prop("checked", false);
$(this).removeAttr('vs');
});
}
});
//批量删除
jQuery("#lock").click(function(){
var daV='';
$('input[vs="t1"]:checkbox').each(function(){
daV+=$(this).attr('id')+',';
});
if(daV){
$.ajax({
type: "POST",
url: "{{=URL('lock_batch')}}",
data: {'all_ids':daV},
dataType: "json",
success:function(data){
if (data==0){
window.location.href="{{=URL('index')}}"
}
}
});
}
});<pre name="code" class="javascript">忘记附上删除的功能
function btn_remove(it){
if($(it).attr("vs")=='t1'){
$(it).removeAttr('vs');
}else{
$(it).attr('vs','t1');
}
}
jquery 复选框以及批量删除
最新推荐文章于 2022-11-20 21:26:34 发布