[Javascript] dynamically hide an element

Nick Fitzsimons nick at nickfitz.co.uk
Wed Nov 29 06:53:32 CST 2006


On 29 Nov 2006, at 13:25:28, Flávio Gomes wrote:

>  What I'm going to talk is css related, but I believe it fits in  
> the topic:
>
>  If you set display to none the element disappears, period.
>
>  But when you want it to be shown again you have to take care on  
> which of the options to take, inline or block.
>
>  If you set it to "block" it'll create a line break after and  
> before the selected element. For a DIV that wouldn't be a great  
> problem, but for an image or a form element It'd be.
>

The thing to do if you might be setting the value of "display" on  
either block or inline elements is to set it to the empty string "".  
That way, it will just revert to its default value, or any value  
specified in a stylesheet that overrides the default. But generally,  
the class-setting technique described earlier in this thread by Mark  
Kelly is the best way to go, if possible.

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/






More information about the Javascript mailing list