Events are actions that occur, for example when a user clicks on a HTML element such as a button
the instructions inside the javascript is executed - this instruction could be to display the date.
Have a look at some of the javascript event handlers, in the table below.
Event Handlers
Explanation
onblur()
Focus is removed from an element
onchange()
The content of a form element changes
onclick()
An event occurs when the mouse clicks on an element
onfocus()
An element gets focus
onkeypress()
A key on the keyboard is pressed down and released
onload()
An event occurs once the object has loaded
onmouseover()
The mouse is moved over an element
onmouseout()
The mouse is moved away from an element
onreset()
A form is reset
onsubmit()
A form is submitted
Example: onfocus and onblur
<script>
function blurOn(x)
{
var text1=document.getElementById(x);
text1.value="focus is off";
text1.style.color="red";
}
function focusOn(x)
{
var text1=document.getElementById(x)
text1.value="focus is on";
text1.style.color="blue"
}
</script>