&nbs"/> &nbs">

Home  >  Article  >  Web Front-end  >  Execute script when mouse wheel scrolls up or down on HTML element?

Execute script when mouse wheel scrolls up or down on HTML element?

王林
王林forward
2023-09-23 10:49:021360browse

Execute script when mouse wheel scrolls up or down on HTML element?

onwheel Property triggered when the mouse wheel scrolls up or down on the element. You can try running the following code to achieve onwheel property -

Example

<!DOCTYPE html>
<html>
   <body>
      <h3 id = "myid" onwheel = "mouseWheel()">
         This is demo heading.
      </h3>
      <p>Click above and use mouse wheel to change the heading color.</p>
      <script>
         function mouseWheel() {
            document.getElementById("myid").style.color = "red";
         }
      </script>
   </body>
</html>

The above is the detailed content of Execute script when mouse wheel scrolls up or down on HTML element?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete