js 設置多個復選框選中和取消選中
阿新 • • 發佈:2017-07-17
設置 function func value pos true val .ajax alert // 設置選中
function setCheckboxClick(obj)
{
if(obj == null)
{
$.messager.alert(‘警告‘, "請選擇要設置選中的項!",‘warning‘);
}
// alert(obj.value);
var authorityId = obj.value;
$.ajax({
type: ‘post‘,
url: ‘getAuthorityByAuthorityId.action‘,
data: {"authorityId" : authorityId},
dataType: ‘json‘,
success:function(data)
{
console.info(data);
var d = $.parseJSON(data);
//$(":checkbox[name=authorityId]").prop("checked",false);
// obj.checked = true;
$(":checkbox[name=authorityId]").each(function(){
var currentAuthorityId = $(this).val();
for(var i = 0; i < d.length; i++)
{
if(currentAuthorityId == d[i].authorityId)
{
// $(this).prop("checked",true);
if ($(this).prop("checked") == true)
{
$(this).prop("checked", false);
}
else
{
$(this).prop("checked",true);
}
}
}
});
},
error:function()
{
}
});
js 設置多個復選框選中和取消選中