Hiding/Showing Elements with javascript

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

I'm having some more problems with javascript.

I needed some script to hide and show elements of my page in response to
certain actions. So my script uses document.getElementById and sets
style.display='none' to hide the element, and sets style.display='block' to
display it.

This seemed to be working fine in IE7 but I found out it looked totally
wrong in FireFox and Opera. (Sorry that I don't have a link.)

It turns out that this is caused by setting display to block that is messing
up the formatting on objects like table rows (tr).

Is anyone familiar with this behavior? I seem to have resolved this issue by
showing items with style.display='' but I'm not sure if this is
non-standard, or perfectly standard.

Any comments would be welcome on the best way to hide and show elements
without altering their appearance.

Thanks.
 
Back
Top