var mydiv = document.getElementById("mydiv");
console.log("offset width = " + mydiv.offsetWidth);
console.log("client width = " + mydiv.clientWidth);
#div1 {
height: 5000px;
width: 5000px;
background-color: #000000;
}
<div id="mydiv">
<div id="div1"></div>
</div>
I have a div on a webpage where the content requires a vertical scrollbar. Using javascript, I'm trying to calculate the offsetWidth and clientWidth so that I can ultimately calculate the width of the vertical scrollbar but apparently they are equal. I have:
html:
<div id="mydiv">
<div id="div1"></div>
</div>
css:
#div1 {
height: 5000px;
width: 5000px;
background-color: #000000;
}
js:
var mydiv = document.getElementById("mydiv");
console.log("offset width = " + mydiv.offsetWidth);
console.log("client width = " + mydiv.clientWidth);