Posted By

iqwebdev on 07/14/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dubogii


Get X, Y Coordinates of Mouse Within Box


 / Published in: jQuery
 

  1. $(function() {
  2. $("#demo-box").click(function(e) {
  3.  
  4. var offset = $(this).offset();
  5. var relativeX = (e.pageX - offset.left);
  6. var relativeY = (e.pageY - offset.top);
  7.  
  8. alert("X: " + relativeX + " Y: " + relativeY);
  9.  
  10. });
  11. });

Report this snippet  

You need to login to post a comment.