Get full height of a clipped DIV

前端 未结 6 1032
小鲜肉
小鲜肉 2020-12-14 06:03

How do I get the height of the div which includes the clipped area of the div ?

content
conte
6条回答
  •  借酒劲吻你
    2020-12-14 06:53

    This works in all cases, whether you have a text node inside or a container. This is using jquery, but you don't need to.

    //return the total height.
    totalHeight = $('#elem')[0].scrollHeight;
    //return the clipped height.
    visibleHeight = $('#elem').height();
    

    $('#elem')[0] is returning the dom element from the jquery call. so you can use that on any dom elem using plain ol' javascript.

提交回复
热议问题