Home >Web Front-end >JS Tutorial >Implementation code to obtain the relative position of the mouse in a div_javascript skills

Implementation code to obtain the relative position of the mouse in a div_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:06:031236browse
复制代码 代码如下:


JS获取DIV相对坐标





我是DIV,经测试,有2PX的误差...

当前鼠标坐标为:
X:
Y:






如果不对,可以试试将

document.documentElement.scrollLeft

替换成

document.body.scrollLeft
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn