我的代码如下: 现在我实现了Checkbox 全选,但是一旦全选后我想执行被选上的脚本事件。 用Jquery实现!!!!  各位有什么好方法没! 我这个方法遍历的太多次了! 等十几秒才触发事件!!!!!    求高手解决
如下是我的全选的脚本事件:
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');
  })
}如下是:全选后的chenkbox的事件
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";
  })  }
 
如下是: 我全选的checkbox控件:
<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');" />

解决方案 »

  1.   

    当你点击全选的时候你就执行你的jq事件http://hi.baidu.com/meimengxuer/blog/item/021bf7250d985c19918f9d0a.html
      

  2.   

    为你的 checkbox 加上 onchange 事件如果你详细描述的话,可能会有更简便的写法
      

  3.   

    我的是服务器的控件!  onchenge事件没有用、
      

  4.   

    但是用到的onchenge事件真没用!  我试了几次了! 
      

  5.   

    就算给checkbox 一个onchenge事件! 当我单击莫个checkbox的时候就不能执行事件了啊!