簡體   English   中英

禁用提交按鈕

[英]Disabling submit button

嗨,我有以下代碼:

<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);

如果將持續時間傳遞給.show() .hide().show() (即使是較短的持續時間,如1ms),則隱藏和顯示效果將添加到動畫隊列中,因此可以在它們之間使用.delay()方法

對於更通用的延遲執行,請使用setTimeout()函數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM