Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't reliably know what listeners are on an element if you aren't in complete control of the environment. Some libraries manually control event listeners, e.g. jQuery stores them in an object and adds a custom attribute to the element so that when an even occurs, it uses the custom property to look up the listeners for that element and event and calls them. </p> <p>Try:</p> <pre><code>&lt;div id="d0"&gt;div 0&lt;/div&gt; &lt;script type="text/javascript"&gt; var el = document.getElementById('d0') el.addEventListener('click',function(){alert('hey');},false); // Make sure listener has had time to be set then look at property window.setTimeout(function(){alert(el.onclick)}, 100); // null &lt;/script&gt; </code></pre> <p>So to know what listeners have been added, you need to be in complete control.</p> <p><em><strong>Edit:</em></strong></p> <p>To make it clear, there is no <strong>reliable</strong> way to inspect an element with javascript and discover what listeners have been added, or even if any have been added at all. You can create an event registration scheme to track listeners added using your event registration methods. But if listeners are added some other way (e.g. directly by addEventListener) then your registration scheme won't know about them.</p> <p>As pointed out elsewhere, jQuery (and others) can't track listeners that are added directly to elements without using the jQuery event registration methods (click, bind, mouseover, etc.) because they use those methods to register (and call) the listeners.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload