Answers for "Get the position of a div/span tag"

0

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};
}
Posted by: Guest on April-13-2020

Browse Popular Code Answers by Language