Blog

It's a Wonderful Life

Stop event propagation with inline onclick attribute

2019-05-21 20:56 Posted in Learn with HTML , JavaScript

Use event.stopPropagation().

<span onclick="event.stopPropagation(); alert('you clicked inside the header');">something inside the header</span>

For IE: window.event.cancelBubble = true

<span onclick="window.event.cancelBubble = true; alert('you clicked inside the header');">something inside the header</span>