Possible Duplicate:
$(this) OR event.target OR var input = $(this)
I’ve got the following HTML
<span>Foo <b>Bar</b></span>
and the following JS
$("span").mouseover(function(event) {
...
});
When I hover over Foo $(event.target) is the <span> element, but when I hover over Bar $(event.target) is the <b> element
How do I get the element I want without checking if I get the <b>and then selecting the parent!?
Use
event.currentTarget. It’s a reference to the element which has the event listener. To get an in-depth explanation read up on event order, bubbling and capturing. Well worth the time: http://www.quirksmode.org/js/events_order.html