Check if onClick Exists on Element in jQuery



These codes might help you −

$('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
});
Updated on: 2020-02-14T08:01:05+05:30

739 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements