【问题标题】:How to disable all buttons on the page while uploading?上传时如何禁用页面上的所有按钮?
【发布时间】:2011-04-18 20:01:23
【问题描述】:

我在客户端使用 json +jquery。我想在上传文件时禁用页面上的所有按钮。目前我只使用它的 id 禁用上传按钮,如下所示..

$("#upload_attachment_button").addClass('ui-state-disabled');

我想知道是否有办法禁用页面上的其余按钮。我做了一个我想让所有系统都使用的函数,我不想每次调用这个函数时都发送按钮id..

谢谢。

【问题讨论】:

    标签: jquery button


    【解决方案1】:

    这很简单。使用类型按钮选择表单的所有输入元素并禁用它们:

    $("input[type=button]").attr("disabled", "disabled");
    

    【讨论】:

    • 所以如果我想再次启用它们,我应该这样做:$("input[type=button]").attr("disabled", "enabled"); 或什么,因为这对我不起作用。
    • 我用过$("input[type=button]").attr("disabled", false);$("input[type=button]").attr("disabled", true);
    • 你应该使用 $("input[type=button]").removeAttr("disabled");
    猜你喜欢
    • 2015-08-09
    • 2013-03-31
    • 2021-10-24
    • 2012-09-29
    • 2023-03-12
    • 2014-09-10
    • 2011-10-05
    • 1970-01-01
    • 2020-10-17
    相关资源
    最近更新 更多