JS events

      No Comments on 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-HTML-element some-event='some JavaScript'>

Some common HTML events are

onchangeAn HTML element has been changed
onclickThe user clicks an HTML element
onmouseoverThe user moves the mouse over an HTML element
onmouseoutThe user moves the mouse away from an HTML element
onkeydownThe user pushes a keyboard key
onloadThe browser has finished loading the page


<button onclick="myfun();">Click me to say hi</button>
function myfun()


Leave a Reply

Your email address will not be published. Required fields are marked *