这里的第一个问题,我现在已经尝试了很多方法,但仍然无法让它做我想做的事。 这是我当前的代码:
$('#viewPortButtonForth').click(function()
{
state++;
switcher();
$('#viewPortButtonForth').prop('disabled',true);
$('#viewPortButtonForth').attr("disabled", "disabled");
});
更好的描述:
我想在单击后禁用 .click 事件,只是为了在一秒钟后再次启用它。
<div id="viewPortButtonForth">
<img src="stuff/back_and_forth.png">
</div>
基本上我想要的是:
$('#viewPortButtonForth').click(function()
{
state++;
switcher();
disable the click event on itself
wait 1000ms
enable the click event again
});
最佳答案
你可以这样做,
function test()
{
state++;
switcher();
$(this).off("click");
setTimeout(function(){ $(this).on('click',test) },1000);
}
$('#viewPortButtonForth').on('click',test);
关于javascript - Jquery 无法禁用事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24467826/