This page it has the following:

If we want to stop the event (e.g., prevent its default action and stop it bubbling), we can do so with the extended event object's Event#stop method:

$('foo').observe('click', function(event) {

Bubbling is an event flow mechanism in the DOM where events that are designated as "bubbling" (such as your click event), after being dispatched to their target, follow the target's parent chain upwards, checking for and triggering any event listeners registered on each successive target.

In other words, given a DOM like this:

<div id="foo">
  <div id="bar">
    <a href="/something">Click Target!</a>

The click event that is triggered when the anchor is clicked will bubble up through the chain, triggering any click handlers on div#bar and div#foo on the way up.

  • Thank you for such a great answer. It made perfect sense to me.
    – user20377
    Jul 26 '11 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy