0

I need to set the table cell width as 300 as shown in http://jsfiddle.net/Lijo/Q3pa2/3/. But I have a requirement to hide the table till the last line of jQuery is executed. The last jQuery task is to set the display as inline for the div. For this, I have a script as shown in http://jsfiddle.net/Lijo/Q3pa2/2/. In this fiddle, it is not working properly.

I think, the reason is, the div should be disaply:inline before taking the width of table. Is there a workaround to get/set the width of table before the table is displayed?

REFERENCE:

  1. Column width setting - HTML table
Community
  • 1
  • 1
LCJ
  • 22,196
  • 67
  • 260
  • 418

1 Answers1

1

You'll need to quickly show it, get/set the width, then hide it. The user won't see this flicker though, the browser won't have time to render it, this is a common trick to solve your problem. You can't get the width of hidden things.

Your example http://jsfiddle.net/v6P65/

Timm
  • 12,553
  • 4
  • 31
  • 43
  • 1
    Actually you can get the width of hidden things if they are hidden with visibility: hidden. The only problem is that you're using display:none. – Minko Gechev Aug 20 '12 at 13:07