$().mouseMove <— Empty selector in jQuery 1.4
-
23-09-2019 - |
Question
The following bit of code breaks in the upgrade to jquery 1.4:
$().mousemove(
function (e) {
defaults.mouseX = e.pageX;
defaults.mouseY = e.pageY;
});
};
What appeared to be a reasonable fix was adding "html" as the selector, ex: $("html").
The fix works fine - except now when the user mouses off the page, it doesn't register the mouse position beyond the boundaries. When attempting to use the mouse position for a drag, for example, the amount of movement beyond the screen is really important. Anyone got any ideas?
Thanks in advance.
Solution
Prior to 1.4, $()
was a shorthand for $(document)
. With 1.4, it actually produces an empty set (which makes more sense but was irritatingly difficult before).
Just write $(document)
when that's what you need, and all will be well...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow