Events is the main part of of the JavaScript application, events are signals that can generated when specific actions occur. When the user clicks a button an event is generated.
An event is also a action performed on a webpage by the user such as clicking a button or entering text into a textbox for generating an event.
There are different type of Event supported by javascript as given below :-
Onmouse click event is occurs when mouse click on any button.
<html>
<head>
<script>
function sayHello()
{
alert("Hello javascript")
}
</script>
<input type="button" value="click" onclick="sayHello()"/>
</body>
</html>
Output :
Mouseover event will be occurred when the cursor over the control for first time.
<head>
<script>
function OnMouseIn (elem) {
elem.style.border = "4px solid black";
}
function OnMouseOut (elem) {
elem.style.border = "";
}
</script>
</head>
<body>
<div style="background-color:pink; width:350px"
onmouseover="OnMouseIn (this)" onmouseout="OnMouseOut (this)">
<p>Move your mouse in rectangle pointer and see effect </p
</div>
</body>
Output :
its show the effect when mouse over the statement and when mouse out of statement.
<html>
<head>
<script>
function rollover(target){
target.style.background = "red";
}
function rollout(target){
target.style.background = "magenta";
}
</script>
<div onmouseover=
"rollover(this)"
onmouseout="rollout(this)"
> Mouse out of the statement then colour will be changed;
</br> and mouse
in of statement then again colour will be changed </div>
</script>
<head>
<html>
Output :
Others
Languages
Frameworks
Web / Design
Mobile Technology
Sql & Technology
R4R