标签:var top span document pre nan default script scroll
function getOffset( el ) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
}
var x = getOffset( document.getElementById(‘yourElId‘) ).left;
标签:var top span document pre nan default script scroll
原文地址:http://www.cnblogs.com/MSIKRUBY/p/6068799.html