Example 1 — Bind with .mousemove(handler)
Log document coordinates with the deprecated binding shorthand.
$("#target").mousemove(function (event) {
$("#log").text(
"pageX: " + event.pageX + ", pageY: " + event.pageY
);
});
// Prefer: $("#target").on("mousemove", function (event) { … }); How It Works
- Pass a function.
.mousemove(fn)registers the handler (deprecated). - Move inside the element. Each movement calls the function.
- Read coords. Use normalized
pageX/pageY. - Migrate. Swap to
.on("mousemove", fn)in new code.

