I have a div containing a href. The div has a jQuery live click event:
$(".item").live("click", function() {
window.location = this.id;
});
In the div I have a href:
<div class="item" id="/test.html">
<a href="javascript:void(0);" class="test" id="123">link</a>
</div>
Also with a live click event:
$(".test").live("click", function() {
$(".item").unbind('click');
alert(this.id);
});
What I try to achieve is click the div loads the div id as location while clicking the link inside the div does it’s own thing while preventing the div click behavior.
I know I could take the href out of the div but I don’s want that 😉
UPDATED
If you can, use jQuery 1.7 to do the event delegation using
.onand stop the anchor clicks from propagating:http://jsfiddle.net/AuHjA/3/
Otherwise use
.delegateinstead of.live:http://jsfiddle.net/mblase75/AuHjA/4/