[英]How can I get information about events that are bound to an element via live()?
我有一個<a>
標記並將其綁定到兩個事件。 我如何獲取有關附加事件的信息?
以下代碼解釋了我的意思:
<a href="#" id="sample" class="sample-cls">Click me</a>
$(function(){
$('#sample').live("click", function(){
sampleFunction();
})
$('.sample-cls').live("click", function(){
// How to get information that to this link
// is attached another event, that run sampleFunction() ?
})
})
不幸的是, $('#sample').data('events')
不包括通過live()
綁定的事件。
// List bound events:
console.dir( jQuery('#elem').data('events') );
// Log ALL handlers for ALL events:
jQuery.each($('#elem').data('events'), function(i, event){
jQuery.each(event, function(i, handler){
console.log( handler.toString() );
});
});
看到這個
當然,可以進一步增強以滿足您的需求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.