Jquery控件checkboxlist 实例,解决前台操作服务器控件的困难

        var chbarray = [];
        var globalarrary = [];
        $(document).ready(function() {

            //将所有checkbox找出,加入到数组
            $("#OrgPermissContainer tr td input[type='checkbox']").each(function(i, item) {
                chbarray.push({ name: $(item).next()[0].innerHTML, value: item });
            });
            //将所有checkbox找出,加入到数组
            $("#globalPermissionContainer tr td input[type='checkbox']").each(function(i, item) {
                chbarray.push({ name: $(item).next()[0].innerHTML, value: item });
            });

            //为所有的checkbox添加事件
            $("#globalPermissionContainer tr td input[type='checkbox']").click(function() {
                //处理每一个checkbox的单击事件
                var strId = $(this).next()[0].innerHTML;


                if (strId == "添加组织" || strId == '修改组织信息' || strId == '删除组织') {
                    //遍历checkbox数组
             
                    $.each(chbarray, function(i, ele) {
                        if (ele.name == "查看组织信息") {

                            ele.value.checked = true;

                        }
                    });
                }
                if (strId == "添加用户" || strId == '修改用户信息' || strId == '删除用户') {

                    $.each(chbarray, function(i, ele) {
                        if (ele.name == "查看用户信息") {

                            ele.value.checked = true;

                        }
                    });
                }

            });
            
            //为所有的checkbox添加事件
            $("#OrgPermissContainer tr td input[type='checkbox']").click(function() {
                //处理每一个checkbox的单击事件
                var strId = $(this).next()[0].innerHTML;


                if (strId == "添加组织" || strId == '修改组织信息' || strId == '删除组织') {
                    //遍历checkbox数组
                    /*for(var i=0;i<chbarray.length;i++)
                    {
                    if(chbarray[i].name=="查看组织信息")
                    {
                    chbarray[i].value.checked=true; 
                    }
                    }*/
                    $.each(chbarray, function(i, ele) {
                        if (ele.name == "查看组织信息") {

                            ele.value.checked = true;

                        }
                    });
                }
                if (strId == "添加用户" || strId == '修改用户信息' || strId == '删除用户') {

                    $.each(chbarray, function(i, ele) {
                        if (ele.name == "查看用户信息") {

                            ele.value.checked = true;

                        }
                    });
                }

            });



        });

        
    </script>

  

原文地址:https://www.cnblogs.com/sunjunlin/p/2125761.html