码迷,mamicode.com
首页 > 编程语言 > 详细

javascript获取html标记的的绝对定位值

时间:2016-09-23 11:02:39      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

function getElementLeft(element) {
var actualLeft = element.offsetLeft;
var current = element.offsetParent;
while (current !== null) {
actualLeft += current.offsetLeft;
current = current.offsetParent;
}
return actualLeft;
}

function getElementTop(element) {
var actualTop = element.offsetTop;
var current = element.offsetParent;
while (current !== null) {
actualTop += current.offsetTop;
current = current.offsetParent;
}
return actualTop;
}

javascript获取html标记的的绝对定位值

标签:

原文地址:http://www.cnblogs.com/huangf714/p/5899090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!