jQuery: Can I get a reference to the bound events on an element?

前端 未结 2 1506
走了就别回头了
走了就别回头了 2021-02-06 05:26

I have some elements with a function bound to the click event. I want to bind that same function instead to the mouseover and mouseout eve

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 05:56

    Try this:

    jQuery('#element').data('events');
    

    You can also do this:

    jQuery.each(jQuery('#element').data('events'), function(i, event){
        jQuery.each(event, function(i, eventHandler){
            console.log("The handler is " + eventHandler.toString() );
        });
    });
    

提交回复
热议问题