1. 程式人生 > >js 多選反選

js 多選反選

lar [1] new pro this spl box true rem

//$(".435__1").attr("checked", true);
//$(".435__0").removeAttr("checked");
$("."+pid+"__1").attr("checked", true);
$("."+pid+"__0:checked").removeAttr("checked");

$(‘input:checkbox‘).click(function () {
var projid_name = $(this).attr("name");
var projid_name_str= new Array(); //定義一數組
projid_name_str=projid_name.split("_");
pname_1 = projid_name_str[0]+"_"+projid_name_str[1]+"_1";
pname_0 = projid_name_str[0]+"_"+projid_name_str[1]+"_0";
if(projid_name_str[2]==1){
$("input[name="+pname_0+"]:checked").removeAttr("checked");
}else if(projid_name_str[2]==0){
$("input[name="+pname_1+"]:checked").removeAttr("checked");
}
});

/*
$("#435 :checkbox[checked]").each(function(i){
valArr[i] = $(this).val();
});
*/

js 多選反選