jQuery Event - mousemove() Method

Example

Get the position of the mouse pointer on the page:

$("document").mousemove(function(e){
  $("span").text(e.pageX + ", " + e.pageY);
});

Try It Yourself

Definition and Usage

The mousemove event occurs when the mouse pointer moves within the specified element.

The mousemove() method triggers the mousemove event or specifies the function to be executed when the mousemove event occurs.

Note:A mousemove event occurs every time the mouse pointer moves one pixel. Handling all mousemove events consumes system resources. Use this event with caution.

Triggers the mousemove event

Syntax

$(selector).mousemove()

Binds the function to the mousemove event

Syntax

$(selector).mousemove(function)
Parameters Description
function Optional. Specifies the function to be executed when the mousemove event occurs.

Try It Yourself