I want to fire an event when I click on a div, but I do not want this event to fire if I click on a specific link on that div:
my js
$("#myDiv").not("#myLink").click(function () {
alert("clicked");
});
$("#myDiv:not(#myLink)".click(function () {
alert("clicked");
});
$("body").on('click', '#myLink', function(e) {
e.stopPropagation();
});
my html
<div id="myDiv">
<a href="#" id="myLink">Some link</a>
</div>
Here is jsfiddle
EDIT: Actually my real code is with the On method , I already tried stopPropagation, but in this case it doesn't work
source
share