jQuery find events handlers registered with an object

http://stackoverflow.com/questions/2518421/jquery-find-events-handlers-registered-with-an-object

by smith000monday

HTML

<div id="el">Test</div>
<code>
    <span id="output"></span>
</code>

CSS

div {
    width: 200px;
    height: 100px;
    border: solid 1px red;
}

JavaScript

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

    $.each($._data($('#el').get(0), "events"), function (i, event) {
        output(i);
        $.each(event, function (j, h) {
            output(h.handler);
        });
    });
});

function output(text) {
    $("#output").html(function (i, h) {
        return h + text + "<br />";
    });
}

function copyPast() {
    $.each($._data($('#item_mod').get(0), "events"), function (i, event) {
        console.log(i + "");
        $.each(event, function (j, h) {
            console.log(h.handler + "<br />")
        });
    });
    
}//fn close