72141

Capture all events (click, change, onmouseover, e.t.c) for a given element using jquery

Is there anyway that I can check if an existing element has event handlers attached to it? Suppose a simple javascript method adds a click event to some div.example (sans jquery), so there are not attribute tags, is it possible to then, using jquery, to capture the event that was attached? I tried to accomplish this using the code below to no avail:

$( '.example' ).each( function() { var newObj = $(this); $.each($(newObj).data("events"), function(i, event) { alert(i); $.each(event, function(j, h) { alert(h.handler); }); });

});

Answer1:

Try this

$( '#elm1' ).each( function() { $.each($(this).data("events"), function(i, event) { alert(i); $.each(event, function(j, h) { alert(h.handler); }); }); });

Recommend

  • what can i do if for loop repeat single row from mysql database?
  • CSS Local Font not showing up
  • Toggle visibility of text box based on status of check box -jQuery
  • Is it safe to accept URL parameters for populating the `url_for` method?
  • apply a javascript function to draggable copy
  • How To Customize ASP.NET Chart Databound To SqlDataSource
  • Android changing fragment order inside FragmentPagerAdapter
  • Ember.js model to be organised as a tree structure
  • How does document.ready work with angular element directives?
  • Unable to install Git-core+svn by MacPorts
  • C: Incompatible pointer type initializing
  • Django simple Captcha “No module named fields” error
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Create DicomImage from scratch using Dcmtk
  • Groovy: Unexpected token “:”
  • Could not find rake using whenever rails
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • FileReader+canvas image loading problem
  • Paperclip, set path outside of rails root folder
  • Recording logins for password protected directories
  • Insert into database using onclick function
  • Splitting given String into two variables - php
  • Deselecting radio buttons while keeping the View Model in synch
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • HTML download movie download link
  • Updating server-side rendering client-side
  • Check if a string to interpolate provides expected placeholders
  • Trying to switch camera back to front but getting exception
  • Weird JavaScript statement, what does it mean?
  • jquery mobile loadPage not working
  • Data Validation Drop Down Box Arrow Disappearing
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • How do you join a server to an Active Directory (domain)?
  • Angular 2 constructor injection vs direct access
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Django query for large number of relationships
  • Programmatically clearing map cache