PDA

View Full Version : DOM Dumb! visibility?


ez4ne12c
12-04-2002, 01:00 AM
if i have a span like this

<span id='fred' style='visibility: hidden;'><img src='picture.gif'></img></span>

how can i check if the image is visible.. i have tried

if (document.fred.style.visibility=='hidden') {alert ("wheres FRED!!!");}

but i dont really think that works

any ideas please?
ez

Vladdy
12-04-2002, 01:15 AM
First of all "document.fred." is not DOM... kinda reminds me of a saying "Bad dancer blames his balls for getting in his way"...
Second, if you set visibility to "hidden" in your style it will be hidden, why check for it :confused: :confused:

glenngv
12-04-2002, 01:15 AM
if (document.getElementById("fred").style.visibility=='hidden') {alert ("wheres FRED!!!");}

btw, it's not DOM :)

ez4ne12c
12-04-2002, 01:24 AM
Thanks for replies
hey Vladdy i have that problem when i dance too!!
i am toggling the visiblility, hence the question...
oh.. i put in title DOM dumb ... which does indicate my DOM knowledge

Thanks
ez

Vladdy
12-04-2002, 01:36 AM
when you set default style in your html file the style.visibility property is NOT set to this value. IE does set currentStyle collection values and Gecko does nothing.
Therefore in you your "flipping" function test for the "other" value.

if((fred=document.getElementById("fred")).style.visibility=='visible') fred.style.visibility = 'hidden';
else fred.style.visibility = 'visible';

so that your else{} code executes first.

ez4ne12c
12-04-2002, 01:46 AM
Thanks again
i will try that
ez