I have the following set-up on my webpage
<div id="clickable">
<a href="hello.com">Here!</a>
</div>
Is there a way I could use to avoid the click event for the div to be triggered. I presume it has something to do with setting something in the onclick attribute for the anchor tag but trying simple things like e.preventDefault() haven’t worked.
Help? Thanks!
e.preventDefault(); wont work in onclick attributes because e is not defined. Also e.preventDefault(); isn’t want you want to stop bubbling, you need e.stopPropagation();
Either use;
on your anchor, or
in your events.