Home  >  Article  >  Web Front-end  >  jQuery: usage and definition of mousemove event

jQuery: usage and definition of mousemove event

黄舟
黄舟Original
2017-06-28 10:21:511795browse

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); });

Example

Get the position of the mouse pointer on the page:

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

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()

Add a function to the mousemove event:

 $(selector).mousemove(function)

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!

Statement:
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