Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Get mouse wheel events in jQuery?

Get mouse wheel events in jQuery using the mousewheel event handler.

Quick Answer: Use the mousewheel event handler to capture mouse wheel events, e.g. $(document).on('mousewheel', function(event) { console.log(event.deltaX, event.deltaY); });

To get mouse wheel events in jQuery, you can use the mousewheel event. However, this event is not a standard jQuery event, so we need to bind it manually.

💡 How to Bind Mouse Wheel Event in jQuery

  • Use the .on() method or the $().on() shorthand.

🚀 Example Code

Binding Mouse Wheel Event with .on()

  1. Step 1: Select the element you want to bind the event to.

Example:

$('.mouse-wheel-element').on('mousewheel', function(event) {

Event object properties: The event object passed to the event handler contains properties such as deltaX, deltaY, and clientX and clientY. These values can be used to determine the direction of the mouse wheel movement.

✨ Example Use Case

You can use the deltaX and deltaY properties to zoom in or out of an image, for example.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions