How do you get the rendered height of an element?

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

    NON JQUERY since there were a bunch of links using elem.style.height in the top of these answers...

    INNER HEIGHT:
    https://developer.mozilla.org/en-US/docs/Web/API/Element.clientHeight

    document.getElementById(id_attribute_value).clientHeight;
    

    OUTER HEIGHT:
    https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.offsetHeight

    document.getElementById(id_attribute_value).offsetHeight; 
    

    Or one of my favorite references: http://youmightnotneedjquery.com/

提交回复
热议问题