有没有比这更短的方法来短时间解除事件绑定(bind)?
$('.test').on('click', function () { alert()});
function pauseEvent() {
$('.test').off('click');
setTimeout(function () {
$('.test').on('click', function () { alert()});// write the whole event again
}, 1000);
}
最佳答案
您可以使用命名函数
function myFunc() {
alert();
}
$('.test').on('click', myFunc);
function pauseEvent() {
$('.test').off('click', myFunc);
setTimeout(function () {
$('.test').on('click', myFunc);
}, 1000);
}
关于javascript - jQuery 解除时间绑定(bind)事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40614837/