Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the width and height of a hidden element

How do I set the width and height of a hidden element by using another hidden element's width and height?

for(i=1;i<10;i++){
   $('#hiddenE1'+i).width($('#hiddenE2'+i).width()).height($('#hiddenE2'+i).height());
}
like image 934
Fergoso Avatar asked Oct 20 '25 15:10

Fergoso


1 Answers

There is no width when display: none. One trick would be to set position: relative; margin-left: -9999px;. It will not show on the page but preserve the width. Or, use visibility: hidden. The only downside is it will not rip it out of the layout but leave a blank spot.

like image 83
beautifulcoder Avatar answered Oct 23 '25 06:10

beautifulcoder