html getBoundingClientRect code example
Example 1: getboundingclientrect() javascript
var div = document.getElementById("myDiv");
var rect = div.getBoundingClientRect();
x = rect.left;
y = rect.top;
w = rect.width;
h = rect.height;
Example 2: what is geBoundingClientRect injs
Return the size of an element and its position relative to the viewport:
var rect = obj.getBoundingClientRect();