我的代码如下: 现在我实现了Checkbox 全选,但是一旦全选后我想执行被选上的脚本事件。  用Jquery实现!!!!
   
     function checkAllstate(o) {        if (o.checked) {
            $("input[id^=FeesShow_ctl10_chkSdate]").attr("checked", true);
                    }
        else {
            $("input[id^=FeesShow_ctl10_chkSdate]").attr("checked", false);        }
    }脚本事件如下:    function chkShowDropDown(sender, keyvalue) {
        $("select[id$='ddl" + keyvalue + "']").each(
            function() {
        this.style.display = sender.checked ? "block" : "none";
            }
        );
        $("[id$='lbl" + keyvalue + "']").each(function() {
        this.style.display = sender.checked ? "none" : "block";
        });
    }被全选的控件如下: <asp:CheckBox  ID="chkSdate1" runat="server"  onclick="chkShowDropDown(this,'AirlineCompany');" /> <asp:CheckBox  ID="chkSdate2"  runat="server"  onclick="chkShowDropDown(this,'AirlineCompany');" /> <asp:CheckBox  ID="chkSdate3"  runat="server"  onclick="chkShowDropDown(this,'AirlineCompany');" />

解决方案 »

  1.   

    function checkAllstate(o) {
      $("input[id^=FeesShow_ctl10_chkSdate]").each(function(){
    $(this).attr("checked", o.checked);
    chkShowDropDown(this,'AirlineCompany');
      });
    }
      

  2.   

    不骗你!   我把代码发你看看!!!  循环的太多了!      
    function checkAllstate1(o) {    $("input[id^=FeesShow_ctl10_chkSdate]").each(function() {
            $(this).attr("checked", o.checked);
          
        chkShowSpan(this, 'Sdate');
        chkShowSpan(this, 'Edate');
        chkShowtable(this, 'CB');
        chkShowDropDown(this, 'AirlineCompany');
        chkShowDropDown(this, '_rateType');
        chkShowDropDown(this, 'Dptype');
        chkShowDropDown(this, 'VoyageType');
        chkShowtextarea(this, 'SE');
        chkShowtextarea(this, 'EE');
        chkShowtextarea(this, 'AircomE');
        chkShowtextarea(this, 'NoAircomE');
        chkShowtextarea(this, 'Cabin2');
        chkShowCloum(this, 'Discount');
        chkShowCloum(this, 'RewardDiscount');
        chkShowCloum(this, 'PolicyType');
        })
      

  3.   

        function chkShowCloum(sender, keyvalue) {
            $("input[id$='txt" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "block" : "none";
            });
            $("[id$='lbl" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "none" : "block";
            });
        }    function chkShowDropDown(sender, keyvalue) {
            $("select[id$='ddl" + keyvalue + "']").each(
                function() {
            this.style.display = sender.checked ? "block" : "none";
                }
            );
            $("[id$='lbl" + keyvalue + "']").each(function() {
            this.style.display = sender.checked ? "none" : "block";
            });
        }
        function chkShowtextarea(sender, keyvalue) {
            $("textarea[id$='txt" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "block" : "none";
            });
            $("[id$='lbl" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "none" : "block";
            });
        }    function chkShowSpan(sender, keyvalue) {
            $("span[id$='txt" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "block" : "none";
            })
            $("[id$='lbl" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "none" : "block";
            })    }
        function chkShowtable(sender, keyvalue) {
          $("table[id$='" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "block" : "none";
            })
            $("[id$='lbl" + keyvalue + "']").each(function() {
                this.style.display = sender.checked ? "none" : "block";
            })    }
    function checkAllstate1(o) {    $("input[id^=FeesShow_ctl10_chkSdate]").each(function() {
            $(this).attr("checked", o.checked);
          
        chkShowSpan(this, 'Sdate');
        chkShowSpan(this, 'Edate');
        chkShowtable(this, 'CB');
        chkShowDropDown(this, 'AirlineCompany');
        chkShowDropDown(this, '_rateType');
        chkShowDropDown(this, 'Dptype');
        chkShowDropDown(this, 'VoyageType');
        chkShowtextarea(this, 'SE');
        chkShowtextarea(this, 'EE');
        chkShowtextarea(this, 'AircomE');
        chkShowtextarea(this, 'NoAircomE');
        chkShowtextarea(this, 'Cabin2');
        chkShowCloum(this, 'Discount');
        chkShowCloum(this, 'RewardDiscount');
        chkShowCloum(this, 'PolicyType');
        })
    }                                <asp:CheckBox  ID="chkSdate0" name="jquerys[]" runat="server" onclick="chkShowSpan(this,'Sdate');" />
                                       <asp:CheckBox  ID="chkSdate1" name="jquerys[]" runat="server"  onclick="chkShowSpan(this,'Edate');" />
                                     <asp:CheckBox  ID="chkSdate2" name="jquerys[]" runat="server"  onclick="chkShowtable(this,'CB');" />
                                     <asp:CheckBox  ID="chkSdate3" name="jquerys[]" runat="server"  onclick="chkShowDropDown(this,'AirlineCompany');" />
                                <asp:CheckBox  ID="chkSdate4" name="jquerys[]" runat="server"  onclick="chkShowDropDown(this,'VoyageType')" />
                                 <asp:CheckBox  ID="chkSdate5" name="jquerys[]" runat="server"  onclick="chkShowtextarea(this,'SE');" />
                                 <asp:CheckBox  ID="chkSdate6" name="jquerys[]" runat="server"   onclick="chkShowtextarea(this,'EE');" />
                                 <asp:CheckBox  ID="chkSdate7" name="jquerys[]" runat="server"  onclick="chkShowtextarea(this,'AircomE');" />
                                 <asp:CheckBox  ID="chkSdate8" name="jquerys[]" runat="server"  onclick="chkShowtextarea(this,'NoAircomE');" />
                                 <asp:CheckBox  ID="chkSdate9" name="jquerys[]" runat="server"  onclick="chkShowtextarea(this,'Cabin2');" />
                                 <asp:CheckBox  ID="chkSdate10" name="jquerys[]" runat="server"  onclick="chkShowCloum(this,'Discount');" />
                                 <asp:CheckBox  ID="chkSdate11" name="jquerys[]" runat="server"  onclick="chkShowCloum(this,'RewardDiscount');" />
                                 <asp:CheckBox  ID="chkSdate12" name="jquerys[]" runat="server"  onclick="chkShowDropDown(this,'Dptype');" />
                                 <asp:CheckBox  ID="chkSdate13" name="jquerys[]" runat="server"  onclick="chkShowCloum(this,'PolicyType');" />
                                 <asp:CheckBox  ID="chkSdate14" name="jquerys[]" runat="server"  onclick="chkShowDropDown(this,'_rateType');" />