How do I prevent a parent's onclick event from firing when a child anchor is clicked?

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:


var url = $("#clickable a").attr("href");

$("#clickable").click(function() {
    window.location = url;
    return true;


<div id="clickable">
    <!-- Other content. -->
    <a href="">I don't want #clickable to handle this click event.</a>

Leave a Comment