我已经制作了这个功能,它应该在点击时提醒,但它也是 按钮被禁用时触发
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();"> Cancel Item</asp:LinkButton>
<asp:HiddenField id="hdnval" value=0 runat="server"/>
答案 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();"> Cancel Item</asp:LinkButton>
<asp:HiddenField id="hdnval" value=0 runat="server"/>