Element clientLeft Property - Get the border size for a <div> with scrollbar: - Javascript DOM

Javascript examples for DOM:Element clientLeft

Description

Element clientLeft Property - Get the border size for a <div> with scrollbar:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {//  w  w  w  . jav  a2s . c om
    height: 250px;
    width: 400px;
    padding: 10px;
    margin: 15px;
    border-left: 10px solid red;
    background-color: lightblue;
    direction: rtl;
    overflow: scroll;
}
</style>
</head>
<body>

<button onclick="myFunction()">Test</button>

<div id="myDIV">
  test test test <br>
  This is a test. This is a test. This is a test.
  This is a test. This is a test. This is a test.
  This is a test. This is a test. This is a test.
  
  <p id="demo"></p>
</div>

<script>
function myFunction() {
    var left = document.getElementById("myDIV").clientLeft;
    document.getElementById("demo").innerHTML = "Border left width: " + left + "px";
}
</script>

</body>
</html>

Related Tutorials