JavaScript Events

JavaScript can make an interaction with HTML using JavaScript events. It occurs when an user or browser manipulates a webpage.
By using events an user can do something in the webpage. An event can be occured several time. Such as when a webpage loads, when a button is clicked or when a window is closed.



Onclick Event

The onclick event is occured when a button of mouse is clicked.

Example:

<input type="button" onclick="helloWorld()" value="Hello World">

Run Example


Some Common JS Events

Here are some mostly used JavaScript events:

JS Events Description
onclick Occurs when an user clicks an element
onsubmit Used to submit a form
onmouseover Occurs when an user moves the mouse over an element
onmouseout Occurs when an user moves the mouse away from an element
onchange Using this an HTML element can be changed
onkeydown Occurs when an user press a keyboard key
onload Occurs when the loading of the browser is finished