/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getElementTopLeft(id) { var ele = document.getElementById(id); var top = 0; var left = 0; while(ele.tagName != "BODY") { top += ele.offsetTop; left += ele.offsetLeft; ele = ele.offsetParent; } return { top: top, left: left }; }
Comments
