如何检查是否存在单击事件在 jQuery 中的元素上?


这些代码可能有帮助 −

$('body').click(function(){ alert('test' )})

var foo = $.data( $('body').get(0), 'events' ).click
// you can query $.data( object, 'events' ) and get an object back, then see what events are attached to it.
 $.each( foo, function(i,o) {
    alert(i) // guid of the event
    alert(o) // the function definition of the event handler
});

更新日期:2020-02-14

612 次浏览

启动你的职业生涯

通过完成课程获得认证

开始学习
广告
© . All rights reserved.