[Javascript] Show and hide multiple div tags
Cutter (JS Related)
java.script at cutterscrossing.com
Thu May 11 21:13:15 CDT 2006
Hey guys! I did say the code was rough and untested:) Just trying to
point folks in the right general direction...
Cutter
_____
http://blog.cutterscrossing.com
Steve Clay wrote:
> Wednesday, May 10, 2006, 5:13:13 AM, Abyss - Information wrote:
>> if(show.style.display=="none")
>
> This is a common mistake.
> Until you've explicitly set the style property via JS or the style
> attribute in the markup, show.style.display will be undefined, not "none"
> or any other CSS value you might expect. That's why your current script
> takes 2 clicks: The display property first goes from (undefined) to "none"
> then finally "block". To suit your purposes, this would work:
>
> show.style.display =
> (!show.style.display || show.style.display=="none")? "block" : "none";
>
>
> The general way to get a "computed" style requires you to use
> window.getComputedStyle or IE/win's currentStyle. Here's one such function:
> http://www.somethingleet.com/forum/showthread.php?threadid=35610
>
> Steve
--
Cutter
____________
http://blog.cutterscrossing.com
"The Past is a Memory
The Future a Dream
But Today is a Gift
That's why they call it
The Present"
More information about the Javascript
mailing list