When the user rolls the mouse wheel over a <div> element, change its font-size: - Javascript DOM Event

Javascript examples for DOM Event:onwheel

Description

When the user rolls the mouse wheel over a <div> element, change its font-size:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {//from  ww  w  .  j ava  2 s . co m
    border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV">
This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.
</div>

<script>
document.getElementById("myDIV").addEventListener("wheel", myFunction);

function myFunction() {
    this.style.fontSize = "35px";
}
</script>

</body>
</html>

Related Tutorials