Search code examples
javascriptjquerylivejquery-eventsevent-bubbling

jQuery event bubbling


I want to understand how exactly to interpret bubbling. Does it mean going up the HTML code hierarchy or something else?

Secondly, I was going through an example and I could not understand the last part where it says

The P-based click handler listens for the click event and then prevents it from being propagated (bubbling up)

What does this mean?


Solution

  • return false;
    

    will prevent "bubbling". It's used to stop default actions like checking a checkbox, opening a select, a click, etc.

    To stop further handlers from executing after one bound using .live(), the handler must return false. Calling .stopPropagation() will not accomplish this.

    From Caveats in jQuery .live()


    Reasoning (thanks to @AlienWebguy):

    The reason stopPropagation() doesn't work with live() is that live() binds the event to document so by the time it fires there's no where else for it to propagate.