How do you get the rendered height of an element?

前端 未结 18 2598
情书的邮戳
情书的邮戳 2020-11-22 03:11

How do you get the rendered height of an element?

Let\'s say you have a

element with some content inside. This content inside is going to st
18条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 03:42

    Have you set the height in the css specifically? If you haven't you need to use offsetHeight; rather than height

    var h = document.getElementById('someDiv').style.offsetHeight;
    

提交回复
热议问题