获得元素的位置。宽、高

function GetElCoordinate(e) {
var t = e.offsetTop;
var l = e.offsetLeft;
var w = e.offsetWidth;
var h = e.offsetHeight;
while (e = e.offsetParent) {
t += e.offsetTop;
l += e.offsetLeft;
}
return {
top: t,
left: l,
w,
height: h,
bottom: t + h,
right: l + w
}
}

原文地址:https://www.cnblogs.com/tanghongbo/p/4160251.html