jQuery Clicking Div Within Div
1 min read

jQuery Clicking Div Within Div

I want a click event on a div, and it will fire anywhere in the div except for the button inside it.

$(".div").click(function() {
    // Click event for the div, I'm slide toggling something
    alert("clicked div");
});

$(".button").click(function(e) {
     e.stopPropagation();
    // Do stuff for the button click, but don't fire event above
    alert("clicked button");
});

source: Event Order