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

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

王林
Release: 2023-09-23 10:49:02
forward
1384 people have browsed it

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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template