Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 3
    +1 for a non-jQuery solution that maintains the same semantics as offsetX and offsetY. Commented Sep 29, 2013 at 22:20
  • 2
    Under Firefox 26.0 there is no field named 'offsetParent' in the event (e) thus initial e.offsetParent does not work ('if' is simply ignored). A solution might be to have e.target.offsetParent Commented Jan 24, 2014 at 8:28
  • @Alex e.target.offsetParent doesn't work either. Did you come up with a fix for this? Commented Feb 5, 2014 at 22:39
  • + 1 - this is the only solution that worked for me, with the only change being using e.target.offsetParent instead of e.offsetParent. I'm using RaphaelJS to draw objects in a map. With this code, I always get the right mouse coordinates even if e.target is sometimes the circle being drawn and sometimes the map canvas. Commented May 25, 2015 at 20:46