Home > Web Front-end > JS Tutorial > body text

jQuery: usage and definition of mousemove event

黄舟
Release: 2017-06-28 10:21:51
Original
1846 people have browsed it

Overview

Bind a handler function to the mousemove event of each matching element.

The mousemove event is triggered by moving the mouse over an element. Event processingThe function will be passed a variable - the event object, its .clientX and .clientY AttributesRepresents the coordinates of the mouse

Parameters

fnFunctionV1 .0

The handler function bound in the mousemove event of each matching element.

[data],fnString,FunctionV1.4.3

data:mousemove([Data], fn) Data can be passed in for function fn to process.

fn: The handler function bound in the mousemove event of each matching element.

Example

Description:

Get the position of the mouse pointer in the page:

jQuery Code:

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

Example

Get the position of the mouse pointer on the page:

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

Definition and usage

When the mouse pointer moves in the specified element, the mousemove event occurs.

The mousemove() method triggers the mousemove event, or specifies a function to run when the mousemove event occurs.

Note: When the user moves the mouse one pixel, a mousemove event will occur. Handling all mousemove events consumes system resources. Please use this event with caution.

Trigger the mousemove event

Syntax

$(selector).mousemove()
Copy after login

Add a function to the mousemove event:

 $(selector).mousemove(function)
Copy after login

Parameters                   Description

function             Optional. Specifies the function to run when the mousemove event fires.


The above is the detailed content of jQuery: usage and definition of mousemove event. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template