find-pos

JS function to find the true position of an element (code from PPK)


Keywords
JavaScript, elements, position, offset
License
GPL-2.0
Install
bower install find-pos

Documentation

findPos()

JS function to find the true position of an element, relative to the page (regardless of scroll position). Code taken straight from http://www.quirksmode.org/js/findpos.html, all credit to PPK.

Usage

var myEl = document.createElement('div');
myEl.style.top = '100px';
myEl.style.top = '100px';
document.body.appendChild(myEl);

var myElPos = findPos(myEl); // [200, 200]