jQuery mousemove()Method

jQuery 事件方法jQuery Event Methods

Examples

Get the position of the mouse pointer in the page:

$(document).mousemove(function(event){
$("span").text(event.pageX + ", " + event.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 adds a function to run when a mousemove event occurs.

Note:Every time the user moves the mouse by one pixel, a mousemove event occurs. Handling all mousemove events consumes system resources. Use this event with caution.


Syntax

Trigger the mousemove event for the selected element:

$(selector).mousemove() Try it Yourself

Add a function to the mousemove event:

$(selector).mousemove(function) Try it Yourself

Parameters Description
function Optional. Specifies the function to run when the mousemove event is triggered.


jQuery 事件方法jQuery Event Methods

Other Extensions