开发者

How can I get information about events that are bound to an element via live()?

I have one <a> tag and bind to it two events. How I can get information about other events attached to it?

The follow code explains what I mean:

<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() ?
    })
})

Unfortunately, $('#sample').data('events') doesn't include the events bound via 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() );
    });
});

See this

Of course, this can be further enhanced to suit your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜