Home>Article>Web Front-end> How does jquery know where the mouse stays?
Method: 1. Use the "$(document).mousemove(function(e){})" statement to add the mouse movement event on the web page, and set the processing function; 2. In the processing function, use " e.pageX" and "e.pageY" statements can dynamically obtain the X and Y axis coordinates of the mouse rest position.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, you can get the position where the mouse stays through the "pageX" and "pageY" attributes.
The pageX property is the position of the mouse pointer, relative to the left edge of the document.
The pageY property is the position of the mouse pointer, relative to the top edge of the document.
That is: the value that will be returned is the position of the mouse on the X-axis and Y-axis.
However, simply using the "pageX" and "pageY" attributes to obtain static positions can be used with mousemove() to obtain dynamic coordinates.
Example:
鼠标指针位于:
[Recommended learning:jQuery video tutorial,web front-end video】
The above is the detailed content of How does jquery know where the mouse stays?. For more information, please follow other related articles on the PHP Chinese website!