jQuery events

jQuery events

by cent cent

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<div id="el">Test</div>
<code>
    <span id="output"></span>
</code>

CSS

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

JavaScript

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

	//x = $._data($("#el")[0], "events" )['click'];
  //console.log(x);
  /*$.each($("#el").data("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 />";
    });
}