Javascipt: Get mouse position relative to parent element
Posted
by Peterim
on Stack Overflow
See other posts from Stack Overflow
or by Peterim
Published on 2010-04-10T18:34:38Z
Indexed on
2010/04/10
18:43 UTC
Read the original article
Hit count: 375
Is there any way to get mouse position relative to it's parent element?
Let's say I have a structure:
<div id="parent">
<span class="dot"></span>
</div>
When I bring my mouse over span
element I need to get its position relative to its parent element (<div id="parent">
). PageX/ClientX give me position relative to page/client area, so it's not working for me.
Any suggestions are greatly appreciated.
Thank you.
© Stack Overflow or respective owner