【问题标题】:Stop the ability to click a button for a while暂时停止单击按钮的能力
【发布时间】:2013-08-20 12:15:58
【问题描述】:

我的网页中有一个下一个按钮和一个上一个按钮,当我单击其中一个按钮时,应该将一些数据加载到页面中。我想在数据加载时停止单击这些按钮的能力。我可以这样做吗???

<div class="final_dates_container">
            <table border="1">
                <tr>
                    <td class="left"><a href="#" onclick="prev_date();"><img class="left_image" src="./include-images/left_arrow.png"/></a></td>

                    <td class="right"><a href="#" onclick="next_date();"><img class="right_image" src="./include-images/right_arrow.png"/></a></td>
                </tr>
            </table>
        </div>

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

是的,如果您使用的是ajax,那么您可以disable 其他buttons 喜欢

预点击功能

$.ajax({
    ....
    beforeSend:function(){
       $('#next').prop('disable',true);// disable next button
    }
    success:function(){
       //your code
       $('#next').removeAttr('disable');// remove disable attribute from here
    }
});

【讨论】:

    【解决方案2】:

    您也可以使用 ajax 全局函数来做到这一点

                $(document).ajaxStart(function () {
                $("#btnSubmit").attr("disabled", true);
            });
            $(document).ajaxComplete(function () {
                $("#btnSubmit").attr("disabled", false);
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多