MBC Computer Solutions Ltd.

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 28 April 2008

Toggling display property on TD element in Firefox has unexpected results

Posted on 11:37 by Unknown

I just encountered a really odd behavior in Firefox.  Basically I was toggling the display property between none and block on a TD element via script:

el.style.display = 'none';
el.style.display = 'block';

The element defaulted to style="display:none".  The first round worked as expected, but after showing and hiding it over and over the results were either that the height kept growing, or the TD element was moving to the right and causing the table to exceed its boundaries.

The solution ended up being to just toggle it between "none" and "":

By default:

<td style="display:none" id="el">

To show it:

$get('el').style.display = '';

To hide it:

$get('el').style.display = 'none';

I'm still not sure what the exact problem was, but maybe this will help someone else out in a jam...

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Blog Archive

  • ►  2012 (1)
    • ►  February (1)
  • ►  2010 (1)
    • ►  April (1)
  • ►  2009 (7)
    • ►  December (1)
    • ►  November (1)
    • ►  October (1)
    • ►  July (1)
    • ►  April (2)
    • ►  February (1)
  • ▼  2008 (36)
    • ►  November (3)
    • ►  October (2)
    • ►  September (1)
    • ►  August (1)
    • ►  July (2)
    • ►  June (6)
    • ►  May (4)
    • ▼  April (1)
      • Toggling display property on TD element in Firefox...
    • ►  March (4)
    • ►  February (7)
    • ►  January (5)
  • ►  2007 (35)
    • ►  December (1)
    • ►  November (9)
    • ►  October (3)
    • ►  September (6)
    • ►  August (7)
    • ►  July (9)
  • ►  2006 (3)
    • ►  May (3)
Powered by Blogger.

About Me

Unknown
View my complete profile