Reputation: 18600
<div style="width:200px; height:200px; background:blue;">
<!-- Other markup -->
<button type="button">Special Button</button>
</div>
(function ($) {
$("div").click(function () {
alert('fired');
// Don't fire when the button is clicking!
});
}(jQuery));
How can I architect the code/html to not fire the "div" click binding when the button is clicked? Here's a jsfiddle to play around with.
Upvotes: 0
Views: 499
Reputation: 388316
You need to prevent event propagation from the button
$('div button').click(function(event){
event.stopPropagation()
})
Demo: Fiddle
Upvotes: 4