O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stopping Event Bubbling Up to Other Elements

function myEventHandler(e){   ...handler code...   e.stopPropogation();   return false; }

Often, you don’t want an event to bubble up to parent objects because you have already handled it in a child object. JavaScript provides a simple way to stop bubbling from occurring. Calling the event.stopPropagation() method on the event object passed to the handler stops the event from bubbling up to parent elements. The event still triggers the default handlers in the browser that provide the web page interaction, such as selecting a check box or activating a link.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required