Javascript examples for DOM:Element clientLeft
The clientLeft property returns the size of left border of an element, in pixels.
This property is read-only.
A Number, representing the size of an element's left border, in pixels
The following code shows how to get the width of a <div> element's top and left border:
<!DOCTYPE html> <html> <head> <style> #myDIV {/* www . j a v a 2 s . c o m*/ height: 250px; width: 400px; padding: 10px; margin: 15px; border-top: 15px solid black; border-left: 10px solid red; background-color: lightblue; } </style> </head> <body> <p>Click the button to get the width of the div's top and left border, in pixels.</p> <button onclick="myFunction()">Test</button> <div id="myDIV"> <p id="demo"></p> </div> <script> function myFunction() { var elmnt = document.getElementById("myDIV"); var txt = "Border top width: " + elmnt.clientTop + "px<br>"; txt += "Border left width: " + elmnt.clientLeft + "px"; document.getElementById("demo").innerHTML = txt; } </script> </body> </html>