Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

div element position in screen

function offset(el) {    var rect = el.getBoundingClientRect(),    scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,    scrollTop = window.pageYOffset || document.documentElement.scrollTop;    return { top: rect.top + scrollTop, left: rect.left + scrollLeft }}
// example usevar div = document.querySelector('div');var divOffset = offset(div);console.log(divOffset.left, divOffset.top);
Source by plainjs.com #
 
PREVIOUS NEXT
Tagged: #div #element #position #screen
ADD COMMENT
Topic
Name
3+2 =