Get relative mouse position


/ Published in: jQuery
Save to your folder(s)

courtesy Jean-Baptiste Jung


Copy this code and paste it in your HTML
  1. function rPosition(elementID, mouseX, mouseY) {
  2. var offset = $('#'+elementID).offset();
  3. var x = mouseX - offset.left;
  4. var y = mouseY - offset.top;
  5.  
  6. return {'x': x, 'y': y};
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.