Events
๐ Events are actions or occurrences done by the user that happens in the system, and as a result the code will trigger a desire react to those events.
๐ When JavaScript is written with HTML, JavaScript can react to those HTML elements.
Why do we need Events ?
๐ Events are required to track user movements when he/she is looking into the website.
๐ Events also help us to produce a output in respect to the user inputs and deliver him/her the desired result.
Here are some Common Events ๐
onChange
๐ Executes a JavaScript when a user changes the selected option of a element.
<select onchange="myFunction()">
onClick
๐ The onClick() event executes a JavaScript when a user clicks on an element.
<button onclick="myFunction()">Click me</button>
onMouseOver
๐ The onMouseOver event occurs only when the user moves the mouse pointer onto an element, or onto one of it's children.
<img onmouseover="bigImg(this)" src="smiley.gif" alt="Smiley">
onMouseOut
๐ The onMouseOut event occurs only when the user moves the mouse pointer out of an element, or out from one of it's children
<img onmouseout="normalImg(this)" src="smiley.gif" alt="Smiley">
onKeyDown
๐ The onKeyDown event occurs when the user presses a key in the website.
<input type="text" onkeydown="myFunction()">
onLoad
๐ The onLoad event is executed when an object has been loaded.
๐ The onLoad event can be used to deal with the cookies of the website
๐ It can also be used to check visitor's browser type and browser type.
<body onload="myFunction()">
If you liked my content, connect with me? ๐