jQuery mousemove() Method
jQuery mousemove() event occurs when a mouse pointer moves with in the selected element. The jQuery mousemove method triggers the mousemove event, and when the event occurs specified function will execute.
Syntax
This syntax represent to the mousemove() method
$(selector).mousemove(); // This syntax does not accept any arguments.
and this syntax represent to attach a function to the mousemove event
$(selector).mousemove(function);
Parameter | Type | Description |
---|---|---|
function | Function | Optional. Specifies the function to execute when the mousemove is occurs |
Examples
This example represent the mousemove event
$(document).ready(function(){
$("button").mousemove(function(e){
$("button").after("<p>Mouse position: X: " + e.pageX + ", Y: " + e.pageY + "</p>");
});
$("button").click(function(){
$(this).mousemove();
});
});
This example represent to attach a function to the mousemove event.
$(document).ready(function(){
$(document).mousemove(function(e){
$("span").text("X: " + e.pageX + ", Y: " + e.pageY);
});
});