The width of an element that has CSS visibility: hidden
is measurable. It's only when it's display: none
that it's not rendered at all. So if it's certain the elements are going to be absolutely-positioned (so they don't cause a layout change when displayed), simply use css('visibility', 'hidden')
to hide your element instead of hide()
and you should be OK measuring the width.
Otherwise, yes, show-measure-hide does work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…