禁用提交按钮

Disabling submit button

本文关键字:按钮 提交      更新时间:2023-09-26

你好,我有以下代码:

<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> 
</script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(document).ready(function()
{
    $('#yourSubmitId').click(function()
    {
        /*$(this).attr('disabled',true);*/
        $(this).prop('disabled',true);
        $(this).css({display:'none'});
        /* your submit stuff here */
        return false;
    });
    /*refreshing the page bringas back the submit button*/
    window.location.reload();
});
//--><!]]>
</script>
</head>
<body>
<h2>Test disabling submit button for 1 minute...</h2>
<br/>

<form id="yourFormId" name="yourFormId" method="post" action="#">
<input type="image" id="yourSubmitId" name="yourSubmitId" src="C:'images 
'submitButton_grey.jpg" alt="Submit" />
</form>
</body>
</html>

当前提交按钮被禁用和隐藏后,它已被按下。

如何刷新页面,以便在按下提交按钮1分钟后才恢复提交按钮?

谢谢,

如果在display:'none'中按钮将被隐藏,那么您实际上不需要禁用该按钮,如果您只是取消隐藏按钮,则不需要刷新页面。所以你可以这样写:

$(this).hide(1).delay(60000).show(1);

如果你传递一个持续时间给.hide().show()(即使是像1ms这样的短持续时间),那么隐藏和显示效果被添加到动画队列中,因此你可以在它们之间使用.delay()方法。

对于更一般的延迟执行使用setTimeout()函数