当按钮被禁用jquery时警报会怎样?

时间:2017-05-22 06:08:50

标签: jquery

  

我已经制作了这个功能,它应该在点击时提醒,但它也是   按钮被禁用时触发

checker = $("#CP_Main_btnCancelItem").button().click(function () {
              var checkedCount = $('#CP_Main_gvPOItems input[type=checkbox]:checked').length;
              if (checkedCount == 0) {
                  alert('No check-box is selected');
              }
          });

.ASPX

<asp:LinkButton CssClass="btn btn-primary" ID="btnCancelItem" runat="server" CausesValidation="False"OnClientClick="return Confirmationbox();">&nbsp;Cancel Item</asp:LinkButton>
<asp:HiddenField id="hdnval" value=0 runat="server"/>

1 个答案:

答案 0 :(得分:0)

要查找元素disable属性,您需要使用:disabled

    checker = $("#CP_Main_btnCancelItem").button().click(function () {
                var checkedCount = $('#CP_Main_gvPOItems input[type=checkbox]:checked').length;

    var isDisabled  = $(checkedCount).is(':disabled');

                  if (isDisabled) {
                      alert('No check-box is selected');
                  }
              });

标记

<asp:LinkButton CssClass="btn btn-primary" ID="btnCancelItem" runat="server" CausesValidation="False"OnClientClick="return Confirmationbox();">&nbsp;Cancel Item</asp:LinkButton>
<asp:HiddenField id="hdnval" value=0 runat="server"/>