Home >Web Front-end >HTML Tutorial >Execute script when mouse wheel scrolls over HTML element?

Execute script when mouse wheel scrolls over HTML element?

PHPz
PHPzforward
2023-09-14 17:57:081431browse

Execute script when mouse wheel scrolls over HTML element?

The onwheel property fires when the mouse wheel scrolls over the element.

Example

You can try running the following code to execute the script when the mouse wheel scrolls over an element in HTML -

<!DOCTYPE html>
<html>
   <head>
   </head>
   <body>
      <div id = "myDIV" onwheel = "display()">This is demo text. Roll the mouse wheel here.</div>

      <script>
         function display() {
            alert("Mouse Wheel used!");
         }
      </script>

   </body>
</html>

The above is the detailed content of Execute script when mouse wheel scrolls over 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