I have an anchor structure as
<a href="#" class="someClass1">
<span><img src="expand.png"/></span>
<span><a class="someClass2" href="abc.html">abc</span>
</a>
Now both the anchors have handler events defined –
$(".someClass1").click(function() {
//do something
return false;
});
$(".someClass2").click(function() {
return true;//navigate to link
});
Now the problem I am facing is if user clicks on the img its fine so just to expand the context menu but if user clicks on the anchor with class someClass2, it should navigate to the designated page, but the parent handler stops this call.
I can’t move the parent handler from a.someClass1 to span due to some other reason. So is there any mechanism with which I can prevent the parent handler call.
PS. This is from Jquerymobile.js I am using for my wordpress site theme creation.
JSFiddle: http://jsfiddle.net/subhash9/2VMm9/
You probably need event.stopPropagation() to stop the propagation of the event further up in ancestor hierarchy.
http://api.jquery.com/event.stopImmediatePropagation/