jQuery: Get height of hidden element in jQuery

后端 未结 14 2243
南方客
南方客 2020-11-22 09:49

I need to get height of an element that is within a div that is hidden. Right now I show the div, get the height, and hide the parent div. This seems a bit silly. Is there a

14条回答
  •  旧时难觅i
    2020-11-22 10:26

    I ran into the same problem with getting hidden element width, so I wrote this plugin call jQuery Actual to fix it. Instead of using

    $('#some-element').height();
    

    use

    $('#some-element').actual('height');
    

    will give you the right value for hidden element or element has a hidden parent.

    Full documentation please see here. There is also a demo include in the page.

    Hope this help :)

提交回复
热议问题