0

在 div 点击事件上,我希望禁用图像的点击事件,如何做到这一点?我尝试解除绑定,但似乎只有在事件为 bind() 时才有效??

$(div).click(function ()
{
//disabled click for images while function Executes 

});
4

2 回答 2

0

你可以做的是:

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);
});
于 2013-05-25T16:19:10.207 回答
0
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
});
于 2013-05-25T16:19:24.050 回答