+ -
当前位置:首页 → 问答吧 → 用Jquery实现全选后能够执行被选中的checkbox脚本事件!

用Jquery实现全选后能够执行被选中的checkbox脚本事件!

时间:2011-12-02

来源:互联网


我的代码如下: 现在我实现了Checkbox 全选,但是一旦全选后我想执行被选上的脚本事件。 用Jquery实现[i][/i]!!!!

  各位有什么好方法没! 我这个方法遍历的太多次了! 等十几秒才触发事件!!!!!

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');" />
 

作者: yy2433720   发布时间: 2011-12-02

$(":checked").each(function(i,item){
$(item).change();
});

作者: ifandui   发布时间: 2011-12-02

刚刚接触Jquery不怎么会! 不知道咋搞! 希望高手们一步步告诉我搞啊!

作者: yy2433720   发布时间: 2011-12-02