JavaScript Events
JavaScript Events
JavaScript Events
The change in the state of an object is known as an Event. In html, there are various events
which represents that some activity is performed by the user or by the browser.
Mouse events:
Event Performed Event Handler Description
mouseover onmouseover When the cursor of the mouse comes over the element
mousedown onmousedown When the mouse button is pressed over the element
mouseup onmouseup When the mouse button is released over the element
Keydown & Keyup onkeydown & onkeyup When the user press and then release the key
Form events:
Event Event Description
Performed Handler
change onchange When the user modifies or changes the value of a form
element
Example No. 1.
<html>
<body>
<script language="Javascript" >
function clickevent()
{
document.write("Students of BCA Class");
}
</script>
<form>
<input type="button" onclick="clickevent()" value="Who's this?"/>
</form>
</body>
</html>
Example 2.Note: Kindly change image names as per availability on your device.
<html>
<head>
<script language="javascript">
function Mouseover()
{
document.a1.src = "Jellyfish.jpg";
}
function Mouseout()
{
document.a1.src = "Desert.jpg";
}
</script>
</head>
<body>
<img name="a1" src="Desert.jpg" width="650px" height="550px"
onMouseOver="Mouseover()" onMouseOut="Mouseout()">
</body>
</html>