Find the “potential” width of a hidden element

前端 未结 10 1331
慢半拍i
慢半拍i 2020-12-03 09:31

I\'m currently extending the lavalamp plugin to work on dropdown menus but I\'ve encountered a small problem. I need to know the offsetWidth of an element that

10条回答
  •  时光取名叫无心
    2020-12-03 10:21

    thats because its hidden via display: none; What ive done in the past is to make a "reciever" div which i use absolute positioning on to get it off the page. Then i load the new element into that, grab the dimensions and then remove it when im done - then remove the reciever when im done.

    Another thing you can do is to not use hide(); but to instead set visibility: hidden; display: ; However this means the blank area will be rendered wherever the node is attached.

提交回复
热议问题