Explain Events in Javascript?

Javascript has events to provide a dynamic interface to a webpage. These events are hooked to elements in the Document Object Model(DOM).

These events by default use bubbling propagation i.e, upwards in the DOM from children to parent. We can bind events either as inline or in an external script.

There are some javascript events:

  • onclick events: This is a mouse event and provokes any logic defined if the user clicks on the element it is bound to.
  • onkeyup event: This event is a keyboard event and executes instructions whenever a key is released after pressing.
  • onmouseover event: This event corresponds to hovering the mouse pointer over the element and its children, to which it is bound to.
  • onmouseout event: Whenever the mouse cursor leaves the element which handles a mouseout event, a function associated with it is executed.
  • onchange event: This event detects the change in value of any element listing to this event.
  • onload event:When an element is loaded completely, this event is evoked.
  • onfocus event: An element listing to this event executes instructions whenever it receives focus.
  • onblur event: This event is evoked when an element loses focus.