Let's say that your DOM element had the ID myElement
.
document.getElementById("myElement").offsetLeft; //Left side of box
document.getElementById("myElement").offsetTop; //Top side of box
document.getElementById("myElement").offsetLeft
+ document.getElementById("myElement").offsetWidth; //Right side of box
document.getElementById("myElement").offsetTop
+ document.getElementById("myElement").offsetHeight; //Bottom side of box
For the bottom and right sides, the code basically adds the width or height of the bounding box to the left or top side.
If you wanted to, you could define document.getElementById("myElement")
once and use the reference, as follows:
var myElement = document.getElementById("myElement");
myElement.offsetLeft; //Left side of box
myElement.offsetTop; //Top side of box
myElement.offsetLeft + myElement.offsetWidth; //Right side of box
myElement.offsetTop + myElement.offsetHeight; //Bottom side of box