[英]How to get jquery/javascript functions to fire once
我正在做一個基於json的多項選擇測驗。 單擊#next按鈕后,它就會淡出並顯示Submit button.button。 我注意到,如果我快速單擊兩次,有時count變量會增加一次以上,並且變量分數也會在用戶正確時增加。 我如何才能將其觸發一次,請先停止觸發,然后再使其再次可點擊。 有人告訴我.off()jQuery方法,但不確定如何使用它。 任何幫助,將不勝感激。
/* report gives score after the last question=array length */
$('#next').on('mousedown',report);
$('#next').on('click', function() {
x++; /* for selecting current question */
count++;
undo(); /* clears question area to load new one from json */
placement(); /* brings in questions in json form */
$(".alert").alert('close'); /* closes dialog */
});
使用jQuery的.one()方法觸發一次事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.