JavaScript basics Web development basics

JS events

In HTML,events are something that browser does or the user does.Some common events that happen are

  • When a HTML page has finished loading.
  • When a button is clicked
  • When any input field is change

JavaScript lets us execute code, when event is executed.HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.

Some common HTML events are

Event Description
onchange An HTML element has been changed
onclick The user clicks an HTML element
onmouseover The user moves the mouse over an HTML element
onmouseout The user moves the mouse away from an HTML element
onkeydown The user pushes a keyboard key
onload The browser has finished loading the page

Example:

Result: