get absolute position of element javascript code example
Example 1: javascript get element position relative to document
element.getBoundingClientRect().top + document.documentElement.scrollTop
Example 2: Get the position of a div/span tag
function getPos(el) {
// yay readability
for (var lx=0, ly=0;
el != null;
lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent);
return {x: lx,y: ly};
}