[Javascript] Removing the Height of a DIV

Dash forgetful54341087097153001984 at hotmail.com
Fri Jul 1 19:39:25 CDT 2005


as i understand:

If you use style.display = 'block' and style.display = 'none' then you dont 
have to touch the height and visibility of the div because changing display 
to none actually makes the html on the page read as though the div doesnt 
exist - rather than just not allowing you to see it. Therefore when display 
is 'none' the div doesn't take up any room.

Dash


----- Original Message ----- 
From: "Flavio Gomes" <flavio at economisa.com.br>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, July 01, 2005 10:09 PM
Subject: Re: [Javascript] Removing the Height of a DIV


> Try this:
>
> (...)
>  if (bShow)    // Show division {
> //   document.getElementById(sLayername).style.visibility = 'visible';
> //   document.getElementById(sLayername).style.height = 'auto';
>   document.getElementById(sLayername).style.display = 'block';
>  }
>  else    // Hide division
>  {
> //   document.getElementById(sLayername).style.visibility = 'hidden';
> //   document.getElementById(sLayername).style.height = '0';
>   document.getElementById(sLayername).style.display = 'none';
>  }
>
> (...)
>
>
> Ps.: I was missing the questions that me and my skills were able to 
> reply... T_T
>
> -- 
> Flavio Gomes
> flavio at economisa.com.br
>
>
>
> Glenn E. Lanier, II wrote:
>
>> I want to show/hide a div based on a radio button selection. I have 
>> everything working somewhat, but I'd like to give the div a height of 0 
>> when it is hidden so I don't have a large "gap" of content.
>>  JavaScript:
>>  function ShowLayer(sLayername, bShow)
>>  {
>>   if (bShow)    // Show division {
>>    document.getElementById(sLayername).style.visibility = 'visible';
>>    document.getElementById(sLayername).style.height = 'auto';
>>   }
>>   else    // Hide division
>>   {
>>    document.getElementById(sLayername).style.visibility = 'hidden';
>>    document.getElementById(sLayername).style.height = '0';
>>   }
>>  }
>> ShowLayer('divPaymentOptions', false);
>>  HTML:
>>  <div id="divPaymentOptions">Varying content, multiple lines</div>
>>  Any thoughts?
>>  Thanks.
>>  --G
>>  ------------------------------------------------------------------------
>> *Glenn E. Lanier II*
>> **/ /*Email: glenn_lanier at netzero.net <mailto:glenn_lanier at netzero.net>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>
>
> 



More information about the Javascript mailing list