CoderZone.org

Category: >> JavaScript >> Get Mouse Position Coordinates Bookmark and Share

<< lastnext >>

Snippet Name: Get Mouse Position Coordinates

Description: Get mouse coordinates inside a div or span.

Also see:
» Simple image resize on mouseover
» Opacity Example
» Move position of mySQL field

Comment: (none)

Author: CoderZone
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: December 01st, 2010

$(function() {
$("#demo-box").click(function(e) {
  var offset = $(this).offset();
  var relativeX = (e.pageX - offset.left);
  var relativeY = (e.pageY - offset.top);
  alert("X: " + relativeX + "  Y: " + relativeY);
});
});
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 6