The mousemove event can fire repeatedly while the pointer moves over an element. Keep the handler lightweight because it may run many times in a short period.
$( selector ).on( "mousemove", function (event) {
// Pointer moved over the element.
});
$( function () {
$( "#d1" ).on( "mousemove", function () {
$( "#t1" ).text( "You moved the mouse inside the box" );
});
$( "#d1" ).on( "mouseout", function () {
$( "#t1" ).text( "You moved the mouse out" );
});
});
To read coordinates during mouse interaction, see event.pageX and event.pageY.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.