javascriptjquerymousewheelmouse-position

e.pageX return undefined when mousewheel event on FireFox


I am trying to get mouse position when mousewheel event.

Here is fiddle. https://jsfiddle.net/xta2ccdt/7/

$("#container").on("mousewheel DOMMouseScroll", function (e) {
  e.preventDefault();
  console.log(e.pageX);
  console.log(e);
}
);

It shows undefined.
What's wrong with this implementation?


Solution

  • Try accessing e.originalEvent.pageX instead, that will access the vanilla JS event that looks like working ok in firefox too.

    Looks like this is just a jquery v2 bug. After updating jquery version to jquery 3 in your fiddle it works with e.pageX too.

    https://jsfiddle.net/xta2ccdt/8/