JavaScript onmousewheel eventThe javascript mouse wheel event is the mouse event to navigate the html web page. The mouseListner uses the mouse wheel (onmousewheel) function to get the functionality after rolling the mouse. The mouse rolls up or down the web page and starts to operate the mouse wheel function using javascript. We can use the "onmousewheel" event, but it deprecates in the javascript. We can use the javascript for the "onwheel" attribute instead of the "onmousewheel" event. SyntaxThe following syntax uses the "onmousewheel" function to show the mouse wheel event. The following syntax shows the mouse wheel event with the "mouse wheel" function using the addEventListener event. ExamplesThe following examples show the mouse wheel event with the different methods and functions. Example 1: the following example shows the basic mouse wheel event using javascript. We can use the event on the html tag with the function. Function changes font size and color when the mouse wheel event works. Output: The image shows the activated mouse wheel events output page. Example 2: the following example uses the mouse wheel event. The javascript uses the "mousewheel" event with the addEventListner method. Output: The image shows the activated mouse wheel events output page. Example 3: the following example uses the mouse wheel event. The javascript uses the "onmousewheel" event with the javascript handler. Output The image shows the activated mouse wheel events output page. Example 4: The following example uses the onwheel with the handler function on the body tag. When we scroll the wheel on the web page, the style tag changes and displays as per the handler. Output The image shows the activated mouse wheel events output page. ConclusionThe "onmousewheel" function uses to roll the mouse wheel event, but advanced browsers deprecated the event. We can use the old version of browsers for the mouse wheel event. Next TopicJavaScript onkeyup Event |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India