element.addEventListener(event, listener, useCapture);
- useCapture: It is an optional parameter used to control event propagation. A boolean value is passed where “true” denotes capturing phase and “false” denotes the bubbling phase.
Before clicking the “Click here” button:
After clicking the “Click here” button:
In this example two events “mouseover” and “mouseout” are added to the same element. If the text is hovered over then “mouseover” event occur and RespondMouseOver function invoked, similarly for “mouseout” event RespondMouseOut function invoked.
Before clicking the “Click here” button and hovering over text:
After clicking the “Click here” button and hovering over text: