Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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) {
  event.stop();
});
share|improve this question

1 Answer 1

up vote 12 down vote accepted

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>
  </div>
</div>

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.