The HTML onmouseover attribute is an event handler that triggers a script to execute when the mouse wheel is rolled over an element.
Definition and Usage
➔ It is deprecated.
➔ Modern web development standards recommend using the alternative onwheel event, and it is supported by all major browsers.
Syntax
//In HTML
<element onwheel="myFunction(event)">
// In Javascript object
object.onwheel =function() {myHandler()};
// In Javascript object
object.onwheel = (event) => {
myFunction();
};
// Using EventListener function run on event
document.querySelector("#id").addEventListener("onwheel", myFunction);
// Using EventListener
object.addEventListener("onwheel", (event) => {
myFunction();
});
function myFunction(){
//code goes here..
}
Applies to
This attribute can be used on the following element.
| Attribute | Element |
|---|---|
| onmousewheel | All visible elements |