I want to stop click event from propagating to parent element. This is the HTML code.
<div style="cursor: pointer; display: inline-block; float: right" onclick="if (confirm('Continue?')) { jQuery(this).children().click(); }">
<button style="float: right; pointer-events: none;" class="form-submit-bold btn btn-default form-submit" id="edit-submit-password" name="op" value="Save Password" type="submit">Save Password</button>
</div>
And have attached this jquery event to button element from console
jQuery($0).on('click', function(e) {
alert('hi');
console.log(e);
e.stopPropagation();
});
Now, when I click on the button element using jQuery($0).click();
this alerts 'hi' but then again the alert which should have been triggered on clicking div is shown.
I want to stop this. Why is stopPropagation not working ?