我正在做一个基于 json 的多项选择测验。单击#next 按钮时,它会淡出并显示提交按钮。我注意到,如果我快速单击两次,有时计数变量会增加多次,并且当用户正确时变量分数也会增加。我怎样才能让它发射一次,停止发射然后再次使其可点击。有人告诉我 .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() 方法触发一次事件。
关于javascript - 如何让 jquery/javascript 函数触发一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26487379/