Skip to content

Instantly share code, notes, and snippets.

@pedromg
Created June 9, 2012 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedromg/2898946 to your computer and use it in GitHub Desktop.
Save pedromg/2898946 to your computer and use it in GitHub Desktop.
Use of mouse event offsetX and offsetY in Firefox. With jQuery 1.7.2
$("#element").click(function (ev) {
if(typeof ev.offsetX === "undefined" || typeof ev.offsetY === "undefined") {
var targetOffset = $(ev.target).offset();
ev.offsetX = ev.pageX - targetOffset.left;
ev.offsetY = ev.pageY - targetOffset.top;
}
// now ev.offsetX and ev.offsetY can be used
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment