Get div height with plain JavaScript

前端 未结 10 824
梦毁少年i
梦毁少年i 2020-11-22 17:22

Any ideas on how to get a div\'s height without using jQuery?

I was searching Stack Overflow for this question and it seems like every answer is pointing to jQuery\'

10条回答
  •  伪装坚强ぢ
    2020-11-22 17:43

    One option would be

    const styleElement = getComputedStyle(document.getElementById("myDiv"));
    console.log(styleElement.height);
    

提交回复
热议问题