【问题标题】:disabled button and enabled button when progress bar finish?进度条完成时禁用按钮和启用按钮?
【发布时间】:2019-05-09 15:06:49
【问题描述】:

如何在进度条工作时禁用按钮当进度条完成时,按钮启用。

我的代码不起作用,按钮在开始时没有被禁用。 谢谢。

<div id="progressTimer"></div>

<script>
    function () {
        $("#btnSave").attr('disabled', 'disabled');
    };
</script>

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://www.jqueryscript.net/demo/Easy-jQuery-Progress-Bar-Timer-Plugin-For-Bootstrap-3-progressTimer/js/jquery.progressTimer.js'></script>
<script>



            $("#progressTimer").progressTimer({
                timeLimit: 30,
                warningThreshold: 10,
                baseStyle: 'progress-bar-warning',
                warningStyle: 'progress-bar-danger',
                completeStyle: 'progress-bar-info',
                onFinish: function () {
                    $("#btnSave").removeAttr('disabled');
                }
            });



</script>


<input type="button" value="Save" id="btnSave" />
<div id="progressTimer">
</div>

我期待 该按钮禁用,直到进度条结束。 进度条完成时启用按钮

【问题讨论】:

  • $("#btnSave").prop('disabled', true);
  • 为什么不首先将按钮写为禁用(&lt;input type="button" value="Save" id="btnSave" disabled="disabled" /&gt;),而不是尝试使用 js 禁用它?然后当进度条完成时,您可以删除 disabled 属性。

标签: javascript c# jquery html model-view-controller


【解决方案1】:

启用/禁用按钮使用:

$('#btnSave').prop('disabled', false);
$('#btnSave').prop('disabled', true);`

【讨论】:

    猜你喜欢
    • 2022-10-23
    • 2012-02-17
    • 1970-01-01
    • 1970-01-01
    • 2022-07-19
    • 2017-01-03
    • 1970-01-01
    • 2015-04-19
    相关资源
    最近更新 更多