使用jquery在页面加载时禁用按钮? [英] Disable button on page loads using jquery ?

查看:88
本文介绍了使用jquery在页面加载时禁用按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有JQuery代码,我想检查网格中是否没有选中复选框,然后应禁用按钮ON PAGE LOADs

< b> JQUERY

 $('input [type = checkbox]')。change(function(){
disableCheckbox();
});

disableCheckbox = function(){
var count = $('input [type = checkbox]:checked')。length;
$('button')。prop('disabled',count == 0);
};

disableCheckbox();



.aspx

 < asp:TemplateField HeaderText =取消SO行项目> 
< ItemTemplate>
< asp:checkbox ID =cbSOCanrunat =serverViewStateMode =EnabledEnableViewState =true>< / asp:checkbox>
< / ItemTemplate>

< asp:LinkBut​​ton CssClass =btn btn-primaryID =btnCancelItemrunat =serverCausesValidation =FalseOnClientClick =return Confirmationbox();> 取消项< / ASP:LinkBut​​ton的>
< asp:HiddenField id =hdnvalvalue = 0 runat =server/>





我尝试过:



 $('input [type = checkbox]')。change(function(){ 
disableCheckbox();
});

disableCheckbox = function(){
var count = $('input [type = checkbox]:checked')。length;
$('button')。prop('disabled',count == 0);
};

disableCheckbox();

解决方案

('input [type = checkbox]')。change(function (){
disableCheckbox();
});

disableCheckbox = function(){
var count =


('input [type = checkbox]:checked')。length;

('button')。prop('disabled',count == 0);
};

disableCheckbox();



.aspx

 < asp:TemplateField HeaderText =取消SO行项目> 
< ItemTemplate>
< asp:checkbox ID =cbSOCanrunat =serverViewStateMode =EnabledEnableViewState =true>< / asp:checkbox>
< / ItemTemplate>

< asp:LinkBut​​ton CssClass =btn btn-primaryID =btnCancelItemrunat =serverCausesValidation =FalseOnClientClick =return Confirmationbox();> 取消项< / ASP:LinkBut​​ton的>
< asp:HiddenField id =hdnvalvalue = 0 runat =server/>





我尝试过:



 


i have JQuery code and i want to check if no checkboxes are checked in grid then button should be disabled ON PAGE LOADs
JQUERY

$('input[type=checkbox]').change(function(){
    disableCheckbox();
});

disableCheckbox = function() {
    var count = $('input[type=checkbox]:checked').length;
    $('button').prop('disabled', count == 0);
};

disableCheckbox();


.aspx

<asp:TemplateField HeaderText="Cancel SO Line Item">
        <ItemTemplate>
        <asp:checkbox ID="cbSOCan" runat="server" ViewStateMode="Enabled" EnableViewState="true"></asp:checkbox>
         </ItemTemplate>

     <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"/>



What I have tried:

$('input[type=checkbox]').change(function(){
    disableCheckbox();
});

disableCheckbox = function() {
    var count = $('input[type=checkbox]:checked').length;
    $('button').prop('disabled', count == 0);
};

disableCheckbox();

解决方案

('input[type=checkbox]').change(function(){ disableCheckbox(); }); disableCheckbox = function() { var count =


('input[type=checkbox]:checked').length;


('button').prop('disabled', count == 0); }; disableCheckbox();


.aspx

<asp:TemplateField HeaderText="Cancel SO Line Item">
        <ItemTemplate>
        <asp:checkbox ID="cbSOCan" runat="server" ViewStateMode="Enabled" EnableViewState="true"></asp:checkbox>
         </ItemTemplate>

     <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"/>



What I have tried:


这篇关于使用jquery在页面加载时禁用按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆