How do you get the rendered height of an element?

前端 未结 18 2596
情书的邮戳
情书的邮戳 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:35

    I made a simple code that doesn't even need JQuery and probably gonna help some people. It gets the total height of 'ID1' after loaded and use it on 'ID2'

    function anyName(){
        var varname=document.getElementById('ID1').offsetHeight;
        document.getElementById('ID2').style.height=varname+'px';
    }
    

    Then just set the body to load it

    
    

提交回复
热议问题