remove - jquery touch events

jQuery find events handlers registered with an object (10)

To check for events on an element:

var events = $._data(element, "events")

Note that this will only work with direct event handlers, if you are using $(document).on("event-name", "jq-selector", function() { //logic }), you will want to see the getEvents function at the bottom of this answer

For example:

 var events = $._data(document.getElementById("myElemId"), "events")


 var events = $._data($("#myElemId")[0], "events")

Full Example:

        <script src="//" type="text/javascript"></script>
            $(function() {
                $("#textDiv").click(function() {
                    //Event Handling
                var events = $._data(document.getElementById('textDiv'), "events");
                var hasEvents = (events != null);
        <div id="textDiv">Text</div>

A more complete way to check, that includes dynamic listeners, installed with $(document).on

function getEvents(element) {
    var elemEvents = $._data(element, "events");
    var allDocEvnts = $._data(document, "events");
    for(var evntType in allDocEvnts) {
        if(allDocEvnts.hasOwnProperty(evntType)) {
            var evts = allDocEvnts[evntType];
            for(var i = 0; i < evts.length; i++) {
                if($(element).is(evts[i].selector)) {
                    if(elemEvents == null) {
                        elemEvents = {};
                    if(!elemEvents.hasOwnProperty(evntType)) {
                        elemEvents[evntType] = [];
    return elemEvents;

Example usage:


I need to find which event handlers are registered over an object.

For example:

$("#el").click(function() {...});
$("#el").mouseover(function() {...});

$("#el") has click and mouseover registered.

Is there a function to find out that, and possibly iterate over the event handlers?

If it is not possible on a jQuery object through proper methods, is it possible on a plain DOM object?

Another way to do it is to just use jQuery to grab the element, then go through actual Javascript to get and set and play with the event handlers. For instance:

var oldEventHandler = $('#element')[0].onclick;
// Remove event handler
$('#element')[0].onclick = null;
// Switch it back
$('#element')[0].onclick = oldEventHandler;

As of jQuery 1.8, the event data is no longer available from the "public API" for data. Read this jQuery blog post. You should now use this instead:

jQuery._data( elem, "events" );

elem should be an HTML Element, not a jQuery object, or selector.

Please note, that this is an internal, 'private' structure, and shouldn't be modified. Use this for debugging purposes only.

In older versions of jQuery, you might have to use the old method which is:

jQuery( elem ).data( "events" );

Events can be retrieved using:


or jQuery 1.8+:

jQuery._data(elem, 'events');

Note: Events bounded using $('selector').live('event', handler) can be retrieved using:


I created a custom jQuery selector that checks against both jQuery's cache of assigned event handlers as well as elements that use the native method for adding them:


    $.find.selectors[":"].event = function(el, pos, match) {

        var search = (function(str){
            if (str.substring(0,2) === "on") {str = str.substring(2);}
            return str;

        if (search) {
            var events = $._data(el, "events");
            return ((events && events.hasOwnProperty(search)) || el["on"+search]);

        return false;





This will return elements that have a click handler attached to them.

I have to say many of the answers are interesting, but recently I had a similar problem and the solution was extremely simple by going the DOM way. It is different because you don't iterate but aim directly at the event you need, but below I'll give a more general answer.

I had an image in a row:

  <td><tr><img class="folder" /></tr><tr>...</tr></td>

And that image had a click event handler attached to it: () { ... });

My intention was to expand the clickable area to the whole row, so I first got all images and relative rows:

tableNode.find("img.folder").each(function () {
  var tr;

  tr = $(this).closest("tr");
  // <-- actual answer

Now in the actual anwer line I just did as follows, giving an answer to the original question:;

So I fetched the event handler directly from the DOM element and put it into the jQuery click event handler. Works like a charm.

Now, to the general case. In the old pre-jQuery days you could get all events attached to an object with two simple yet powerful functions gifted to us mortals by Douglas Crockford:

function walkTheDOM(node, func)
  node = node.firstChild;
  while (node)
    walkTheDOM(node, func);
    node = node.nextSibling;

function purgeEventHandlers(node)
  walkTheDOM(node, function (n) {
    var f;

    for (f in n)
      if (typeof n[f] === "function")
        n[f] = null;

I've combined both solutions from @jps to one function:

jQuery.fn.getEvents = function() {
    if (typeof(jQuery._data) == 'function') {
        return jQuery._data(this.get(0), 'events') || {};
    } else if (typeof( == 'function') { // jQuery version < 1.7.?
        return'events') || {};
    return {};

But beware, this function can only return events that were set using jQuery itself.

In a modern browser with ECMAScript 5.1 /, you can also use

jQuery._data(DOCUMENTELEMENT,'events')["EVENT_NAME"].map(function(elem){return elem.handler;});

in your browser console, which will print the source of the handlers, comma delimited. Useful for glancing at what all is running on a particular event.

You can do it like this:

$("#el").click(function(){ alert("click");});
$("#el").mouseover(function(){ alert("mouseover"); });

$.each($("#el").data("events"), function(i, e) {
//alerts 'click' then 'mouseover'

If you're on jQuery 1.4+, this will alert the event and functions bound to it:

$.each($("#el").data("events"), function(i, event) {
    $.each(event, function(j, h) {
//'function (){ alert("click"); }'
//'function(){ alert("mouseover"); }'

​You can play with it on jsFiddle here