Definition and Usage onmouseover..
The onmouseover event occurs when the mouse pointer is moved onto an element, or onto one of its children.
Syntax :
In HTML: <element onmouseover="myScript">
In JavaScript: object.onmouseover = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("mouseover", myScript);
Definition and Usage onmouseout..
The onmouseout event occurs when the mouse pointer is moved out of an element, or out of one of its children.
Syntax :
In HTML: <element onmouseout="myScript">
In JavaScript: object.onmouseout = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("mouseout", myScript)
CODING:The onmouseover event occurs when the mouse pointer is moved onto an element, or onto one of its children.
Syntax :
In HTML: <element onmouseover="myScript">
In JavaScript: object.onmouseover = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("mouseover", myScript);
Definition and Usage onmouseout..
The onmouseout event occurs when the mouse pointer is moved out of an element, or out of one of its children.
Syntax :
In HTML: <element onmouseout="myScript">
In JavaScript: object.onmouseout = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("mouseout", myScript)
<!DOCTYPE html>
<html>
<body>
<div id="div" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)">
HOVER ME!
</div>
<script>
function mouseOver(x) {
x.style.border = "4pt double lightgreen";
x.style.height = "100px";
x.style.width = "150px";
}
function mouseOut(x) {
x.style.border = "1pt solid green";
x.style.height = "50px";
x.style.width = "100px";
}
</script>
<h1 id="demo">Mouse over me</h1>
<script>
document.getElementById("demo").addEventListener("mouseover", mouseOver1);
document.getElementById("demo").addEventListener("mouseout", mouseOut1);
function mouseOver1() {
document.getElementById("demo").style.border = "2pt solid black";
}
function mouseOut1() {
document.getElementById("demo").style.color = "white";
}
</script>
<script>
document.getElementById("demo").onmouseover = function() {mouseOver2()};
document.getElementById("demo").onmouseout = function() {mouseOut2(this)};
function mouseOver2() {
document.getElementById("demo").style.backgroundColor = "white";
}
function mouseOut2() {
document.getElementById("demo").style.backgroundColor = "black";
}
</script>
</body>
</html>
<html>
<body>
<div id="div" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)">
HOVER ME!
</div>
<script>
function mouseOver(x) {
x.style.border = "4pt double lightgreen";
x.style.height = "100px";
x.style.width = "150px";
}
function mouseOut(x) {
x.style.border = "1pt solid green";
x.style.height = "50px";
x.style.width = "100px";
}
</script>
<h1 id="demo">Mouse over me</h1>
<script>
document.getElementById("demo").addEventListener("mouseover", mouseOver1);
document.getElementById("demo").addEventListener("mouseout", mouseOut1);
function mouseOver1() {
document.getElementById("demo").style.border = "2pt solid black";
}
function mouseOut1() {
document.getElementById("demo").style.color = "white";
}
</script>
<script>
document.getElementById("demo").onmouseover = function() {mouseOver2()};
document.getElementById("demo").onmouseout = function() {mouseOut2(this)};
function mouseOver2() {
document.getElementById("demo").style.backgroundColor = "white";
}
function mouseOut2() {
document.getElementById("demo").style.backgroundColor = "black";
}
</script>
</body>
</html>
Comments
Post a Comment