两个复选框的联动效果

$('input[name="merchantIds"]').each(function(){
    $(this).click(function () {
        var chkStr = "";
        $('input[name="merchantIds"]:checked').each(function(i, o){
            chkStr += $(this).val()+",";
        });
        $.ajax({
            type: "POST",
            url: "shop/findByMerchantIds?merchantIds="+chkStr,
            success: function(msg) {
                if (msg.success) {
                    var obj = msg.obj;
                    $("#shopIdsControl .checkboxSpan").hide();
                    $.each(obj, function(shopIndex, shop){
                        $("#shopIdsControl input[value='"+shop.id+"']").parents(".checkboxSpan").show();
                    });
                }
            }
        });
    });
});

1
2
3
4
5
var arr1 = [ "aaa" , "bbb" , "ccc" ];
$.each(arr1, function (i,val){
alert(i);
alert(val);
});

alert(i)将输出0,1,2 alert(val)将输出aaa,bbb,ccc

你可能感兴趣的:(两个复选框的联动效果)