I have some html.
<a href="#">
<i class="some-bg" />
Some Text
</a>
And some Javascript.
$("a").bind("touchstart", function (e) {
e.preventDefault();
console.log("Tag: " + e.target);
console.log("Tag Name: " + e.target.tagName);
});
The response is.
Tag: [object HTMLElement]
Tag Name: I
Why? Shouldn’t it be anchor?
UPDATED
$("a, a *").bind(function() {
e.stopPropagation();
// other stuff
});
Will this do the trick?
Because you touched the
<i>(and then the event bubbled up to the<a>).No. Use
currentTargetif you want the element to which the event is bound rather then the one which actually triggered the event.