Return the width of the top border of a <div> element:
alert(document.getElementById("myDiv").style.borderTopWidth);
<!DOCTYPE html> <html> <body> <div id="myDiv" style="border-top:thick solid red">This is a div element.</div> <br> <button type="button" onclick="myFunction()">Return the width of the top border</button> <p id="demo"></p> <script> function myFunction() {/*from w ww. j a v a 2 s . c om*/ document.getElementById("demo").innerHTML = document.getElementById("myDiv").style.borderTopWidth; } </script> </body> </html>