Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] dynamically hide an element


  • From: flavio at economisa.com.br (Flávio Gomes)
  • Subject: [Javascript] dynamically hide an element
  • Date: Wed Nov 29 06:25:38 2006

  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.

Mark Kelly escreveu:

>On Wednesday 29 November 2006 00:10, Dong, Roland wrote:
>  
>
>>Hello,
>>
>>I need to dynamically hide and unhide a selection box based on the value
>>selected in the first selection box.
>>    
>>
>
>I did something almost identical recently with help from this list. In the 
>end the best solution (for me at least) was to use CSS classes:
>
>.hidden {display: none;}
>.shown {display: block;}
>
>In the HTML:
><div id="selectbox" class="hidden">concealed selectbox here</div>
>
>And in the Javascript for a simple toggle of the visibility I did:
>
>if( myReference.className != 'hidden' ) {
>    myReference.className = 'hidden';
>    } else {
>    myReference.className = 'shown';
>    }
>
>This way the space collapses back when the div is hidden.
>
>Hope this helps.
>
>Mark
>
>_______________________________________________
>Javascript mailing list
>Javascript@xxxxxxxxxx
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>

-- 
Flavio Gomes
flavio@xxxxxxxxxxxxxxxx