This is a demo for Locating mouse position in jQuery blog post.

On mouse move

e.pageX = 759, e.pageY = 284

Code:

$(document).ready(function(){
  $().mousemove(function(e){
     // e.pageX - gives you X position
     // e.pageY - gives you Y position
     $('#document').html('e.pageX = ' + e.pageX + ', e.pageY = ' + e.pageY);
  });
});

On mouse click

Click inside me

Code:

$(document).ready(function(){
  $('#click').click(function(e){
     // e.pageX - gives you X position
     // e.pageY - gives you Y position
     $('#click').html('e.pageX = ' + e.pageX + ', e.pageY = ' + e.pageY);
  });
});

http://custom-drupal.com/jquery-demo/mouse-position/

Use jQuery to move BG by tracking mouse position?

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_24469701.html

Leave a comment