Hiding/Showing Elements with javascript

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top