禁用提交按钮

Dev*_*v P 0 html javascript css jquery

嗨,我有以下代码:

<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>
Run Code Online (Sandbox Code Playgroud)

目前,提交按钮在按下后被禁用并隐藏.

如何刷新页面以便仅在按下提交按钮后1分钟后返回提交按钮.

谢谢,

nnn*_*nnn 8

如果它仍然被隐藏display:'none',你根本不需要禁用该按钮,如果你只是取消隐藏按钮,则不需要刷新页面.所以你可以这样做:

$(this).hide(1).delay(60000).show(1);
Run Code Online (Sandbox Code Playgroud)

如果您将持续时间传递给.hide().show()(即使是短暂的持续时间,如1毫秒),则隐藏和显示效果会添加到动画队列中,因此您可以在它们之间使用该.delay()方法.

对于更通用的延迟执行,请使用该setTimeout()函数.