2013-03-21 52 views
0

我需要覆蓋事件,但應用程序有一個選項可以將原始事件返回到文檔的每個元素。有任何想法嗎?如何在指定新事件時避免並返回jquery中的事件?

例如:

<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 
    }); 
+0

爲什麼要將多個'click'事件分配給同一個元素? – 2013-03-21 11:56:05

回答

0

嘗試檢查單擊功能事件之前

的$(document).delegate ('.mydiv',點擊',函數() {

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...'); 

}); 
相關問題