0

我需要覆盖事件,但是应用程序可以选择将原始事件返回到文档的每个元素。有任何想法吗?

例如:

    <div class="mydiv">
    </div>

    $(document).delegate( '.mydiv', click', function () { 
        alert('This is the original event my event!');
    });

    $(document).delegate( '.mydiv', 'click', function() {
       alert('Do this and ignore de previous...');
       // For example: How to return the original event when mouseleave event will executed?
    });

    $(document).delegate( '.mydiv', 'mouseleave', function() {
//       return the original event of mydiv 
    });
4

2 回答 2

1

undelegate function在创建new click函数之前使用

文档http://api.jquery.com/undelegate/

于 2013-03-21T11:56:57.733 回答
0

尝试检查函数中的点击事件

$(document).delegate('.mydiv', click', function () {

    if(clicked){
          return;
      }
   alert('This is the original event my event!');

});

$(document).delegate( '.mydiv', 'click', function() {
       if(!clicked){
          return;
      }
   alert('Do this and ignore de previous...');

});
于 2013-03-21T12:10:22.077 回答