Reputation: 93784
HTML:
<a id="test" data-value="1">TEST <i class="fa fa-bank"></i></a>
JS:
var f = function(e) {
console.log($(e.target).data('value'));
};
$('a#test').hover(f, f);
When I hover out from the right side of the anchor. The target of the hover out event will be <i class="fa fa-bank"></i>
. Is there a way that I can force the target be the <a id="test">...</a>
Upvotes: 1
Views: 38
Reputation: 74420
this
inside event handler will refer to the element which event is bound, so you can use instead:
$(this).data('value')
Upvotes: 2