Get border width from a div with plain javascript

前端 未结 6 2132
日久生厌
日久生厌 2020-12-30 23:44

I got this style applied to a div

div#content {
border: 1px solid skyblue;  
}

and i want to be able to alert the width of the border, I ha

6条回答
  •  情深已故
    2020-12-31 00:45

    you can try this

    var border =  document.getElementById("yourDiv").clientWidth - document.getElementById("yourDiv").offsetWidth; 
    alert(border);
    

提交回复
热议问题