Get X, Y Coordinates of Mouse Within Box with jQuery

[javascript]
$(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);

});
});
[/javascript]

Leave a Reply