Jquery prop()与change()冲突解决办法

来源:互联网 发布:每天计划软件 编辑:程序博客网 时间:2024/06/05 14:53

解决方案:
添加change(),让它触发$(“input[type=’checkbox’]”).prop(‘checked’, true).change();

代码实例如下:

$("input[name='paxOdr']:checkbox").change(function(){        console.log("paxOdr>>>>>>>>");        var type = $("#applyMainType").val();        var arip = $("#serviceAirp").val();        if(opt!="'view'" && opt!="view"){            var datas =getCheckDataList('paxStand');//获取改变之前的数据            $("#paxStandList li").remove();            initStandard('1', type, arip, $("#paxStandList"), 'pax','paxStand', 'paxOdr');            $("input[name='paxStand']:checkbox").each(function(i){                ob =  $.parseJSON($(this).val());            $.each(datas,function(m){                if(socVos[m].standId == ob.standId && socVos[m].serviceId == ob.serviceId &&socVos[m].id == ob.id){                    $("input[name='paxStand']:checkbox")[i].checked=true;                }            });        });        }    });

全选时添加change方法

if(value=='paxSerList')$("input[name=paxSer]:checkbox").prop("checked", true);            if(value=='paxList')$("input[name=pax]:checkbox").prop("checked", true).change();            if(value=='paxOdrList')$("input[name=paxOdr]:checkbox").prop("checked", true).change();            if(value=='paxStandList')$("input[name=paxStand]:checkbox").prop("checked", true);            if(value=='crewList')$("input[name=crew]:checkbox").prop("checked", true).change();            if(value=='crewOdrList')$("input[name=crewOdr]:checkbox").prop("checked", true).change();            if(value=='crewStandList')$("input[name=crewStand]:checkbox").prop("checked", true);
原创粉丝点击