Get original element using .on

Posted by RGraham on Stack Overflow See other posts from Stack Overflow or by RGraham
Published on 2013-11-10T08:12:12Z Indexed on 2013/11/10 9:54 UTC
Read the original article Hit count: 165

Filed under:
|

When using jQuery's event delegation, is there a way to retrieve the element on which .on was called, as well as the element on which the event was called?

jQuery:

$(".item").on("click","a",function() {
    var link = $(this); // a tag
    var itemDiv = // what?
});

HTML:

<div class="item">
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
</div>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery