Need to find height of hidden div on page (set to display:none)

前端 未结 13 1620
萌比男神i
萌比男神i 2020-11-27 06:00

I need to measure the offsetHeight of a div that is inside of a hidden element.

13条回答
  •  我在风中等你
    2020-11-27 06:32

    What I wound up having to do was this:

    Using YUI 2, on page load, I found all elements of that given classname that were either set to display:none, or whose height and width was 0 (that's one way of measuring whether an element exists, or a parent is set to display:none). I then set that element to display:block. I then checked it's parent for the same thing and showed the parents until it finds a visible parent. Once highest display:none ancestor is set to display:block, I can measure my element.

    Once all elements are measured I reset all of the elements back to display:none.

提交回复
热议问题