在 div 点击事件上,我希望禁用图像的点击事件,如何做到这一点?我尝试解除绑定,但似乎只有在事件为 bind() 时才有效??
$(div).click(function ()
{
//disabled click for images while function Executes
});
你可以做的是:
var clickEnabled = true;
$(img).click(function (){
if (!clickEnabled) return;
// do your stuff
});
$(div).click(function (){
//start animation
clickEnabled = false;
setTimeout(function(){
//end animation
clickEnabled = true;
}, 666);
});
var areWeAllowedToDoStuff = true;
$(div).click(function () {
areWeAllowedToDoStuff = false;
$.start_whatever_animation(
…, // additional animation parameters
function() { // callback for when animation has finished
areWeAllowedToDoStuff = true;
}
);
});
$("image").click(function() {
if(!areWeAllowedToDoStuff) {
return;
}
// do other stuff here
});