JavaScript is often utilized with events. Computer users interact with Web pages by clicking, double-clicking, dragging, and moving the mouse over various parts of the Web page. Your Web page elements can respond to what the user does by using events. In order to respond to the user's actions, you must set up a response to an event. Your page elements (links, documents, and table rows) have events such as:
click - The click event (when something is clicked)
dblclick - The dblclick event (when something is clicked twice)
focus - The focus event (when something receives the tab our mouse 'attention')
resize - The resize event (when the browser is resized)
unload - The unload event (when the page is unloaded - user leaves the page)
mouseover - The mouseover event (when the mouse moves over something)
mouseout - The mouseout event (when the mouse moves away from something after being over)
Once an event is triggered, you will call a function (code snippet) to run your desired code.