[Javascript] Show and hide multiple div tags

Triche Osborne wdlists at triche-osborne.com
Thu May 11 16:55:53 CDT 2006


Abyss - Information wrote:
> 
> its the "?" and the ":" that have thrown me into confusion
> 

This is what is known as a ternary if statement.

show.style.display =
   (!show.style.display || show.style.display=="none")? "block" : "none";

Written in the common if()/else form, it would look like this:

if (!show.style.display || show.style.display=="none") {

     show.style.display = "block";
} else {
     show.style.display = "none";
}

Does this make sense?

Triche




More information about the Javascript mailing list