Skip to content

View Bound Events from an Element in jQuery

The .data() method is a neat way to find out what data is associated with an element. For example, let’s say we have the following HTML:

<a href="" id="google-link">Click me to proceed.</a>

and we run the following:


We’ll get (in Chrome’s console):

We get an undefined because there are no events bound to it. Now, let’s add some events:

    $("#google-link").click(function(e) {      
      alert("Google link was clicked.");

    $("#google-link").hover(function(e) {      
      alert("Google link was hovered.");

Now let’s view the page and run the data method again in the console.


The results:

Thus it’s very handy, especially when you’re using plugins and they misbehave by randomly hooking themselves into elements, getting in your way.



Dan View All

Blog owner.

%d bloggers like this: