I'm currently using jQuery to make a div clickable and in this div I also have anchors. The problem I'm running into is that when I click on an anchor both click events are firing (for the div and the anchor). How do I prevent the div's onclick event from firing when an anchor is clicked?
Here's the broken code:
JavaScript
var url = $("#clickable a").attr("href"); $("#clickable").click(function() { window.location = url; return true; }) HTML
<div id="clickable"> <!-- Other content. --> <a href="http://foo.example">I don't want #clickable to handle this click event.</a> </div>