Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong><em>[updated]</em></strong><br> The problem is that you are using the wrong tool for the job (namely the event.target property). This will return the element that the event happened <strong>on</strong>.. but not the element in the bubbling phase that handles the event... you need to use the <code>event.currentTarget</code>.. But in jQuery's case this is also the same as the <code>this</code> keyword inside the handler ...<br> ref: <a href="http://api.jquery.com/event.currentTarget/" rel="nofollow noreferrer">http://api.jquery.com/event.currentTarget/</a></p> <p>Have a read at the <a href="http://www.quirksmode.org/js/events_order.html" rel="nofollow noreferrer">Event order</a> as explained at quirksmode. Special attention to <em><a href="http://www.quirksmode.org/js/events_order.html#link6" rel="nofollow noreferrer">Use of event bubbling</a></em> and <em><a href="http://www.quirksmode.org/js/events_order.html#link10" rel="nofollow noreferrer">currentTarget</a></em> <hr /> <strong><em>[previous answer]</em></strong><br> Make sure that inside the <code>.click</code> method you use a function pointer or an anonymous function ..</p> <p>so </p> <pre><code>$("a").click( function() {/*...*/} ); // anonymous function </code></pre> <p>or </p> <pre><code>function some_function() { //... } $("a").click ( some_function ) // function pointer </code></pre> <p>but <strong>not</strong></p> <pre><code>$("a").click ( some_function() ) // unless some_function returns a function pointer.. </code></pre>
 

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