~ JavaScript element getBoundingClientRect code example
Example: getboundingclientrect() javascript
var div = document.getElementById("myDiv");
var rect = div.getBoundingClientRect();
x = rect.left;
y = rect.top;
w = rect.width;
h = rect.height;