What is the event mode of jQuery?

We know there are two event modes in javascript: capture mode and bubble mode. In capture mode, event flows from parent element to child element(i.e. from top to bottom), while in bubble mode, event flows from child element to parent element(i.e. from bottom to top). The mode is determined by the last parameter of addEventListener().

element.addEventListener('click',eventhandler,true);

true means the event handler will be called in capture stage; false means the event handler will be called in bubble stage of event.

In jQuery, there are two methods to add an event handler for an element:

  1. $(element).click(function(){});
  2. $(element).bind('click',function(){});

Both methods bind the function which is called at the bubble stage of event.

Leave a Reply