jqueryexample.com Detect mouse position in jQuery - jqueryexample.com

Detect mouse position in jQuery by jqueryuser

To detect where the mouse was on the page we have to do is to read event object’s .pageX and .pageY properties.

$().mousemove(function(e){
   // e.pageX - gives you X position
   // e.pageY - gives you Y position
});

OR

jQuery(document).ready(function(){  
  $().mousemove(function(e){     
     mouseX = e.pageX;
     mouseY = e.pageY;  
 }); })
Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment