发新帖

[web前端] jquery 全选、反选、取消

零下一度 2018-8-13 1277
//全选
function select_all() {
    $('input[name="param"]').attr('checked','true');
}
//取消
function select_cancel() {
    $('input[name="param"]').each(function () {
        $(this).attr("checked",false);
    })
}
//反选
function select_inv() {
    $('input[name="param"]').each(function () {
        $(this).attr("checked", !$(this).attr("checked"));
    });
}


单一标签事件全选取消切换

$('#checkboxTitle').click(function(){
	if($(this).is(':checked')){
		$('input[name="checkboxList"]').each(function(){ 
			$(this).prop('checked',true);
		});
	}
	else{
		$('input[name="checkboxList"]').each(function () {
			$(this).removeAttr("checked"); 
		})
	}
});



最新回复 (0)
返回
零下一度
主题数
931
帖子数
0
注册排名
1