Click to See Complete Forum and Search --> : How to find the value of visibility


sumon177
03-24-2006, 01:54 PM
How can I find the value of visibility...I am trying do following..
if(document.getElementById("or").style.visibility=="visible")...it does not work.

Thanks

TheBearMay
03-24-2006, 02:03 PM
Has it been explicitly set using a style="visibility:visible" on the element or document.getElementById("or").style.visibility="visible" in javascript? If not it's probably null. (Note: Setting it in a <style> block doesn't always set it either.)

sumon177
03-24-2006, 02:04 PM
Its been set up like....
document.getElementById("or").style.visibility="visible"

TheBearMay
03-24-2006, 02:15 PM
Sooooo, if you do a:


alert("|"+document.getElementById("or").style.visibility+"|");


you get what???

JPnyc
03-24-2006, 02:21 PM
That should work. I used something similar to toggle the forums list on the main page of this site. Actually it was the display property, but that shouldn't matter.

JPnyc
03-24-2006, 02:25 PM
Here's the function I just mentioned
var theseDivs = document.getElementById(ID).childNodes;



for(var j=1; j<theseDivs.length;j++) {
if(theseDivs[j].className=='tab_inner') {
if(theseDivs[j].style.display=="block") {
theseDivs[j].style.display="none";
document.getElementById(ID).firstChild.style.backgroundImage='url(/img/plus.gif)';
}
else {
theseDivs[j].style.display="block";
document.getElementById(ID).firstChild.style.backgroundImage='url(/img/minus.gif)';
}
}
}
}

sumon177
03-24-2006, 02:55 PM
I found the problem..that JS method code(document.getElementById("or").style.visibility="visible") was functioning after the if statement. Now I am calling the fuction inside the fuction with the if statement.

Thansk a lot guys....

sumon177
03-24-2006, 02:57 PM
actually I found that problem once BeerMay mentioned about null values....so, it reall helped.........

TheBearMay
03-24-2006, 03:18 PM
...BeerMay ... Now that's one I haven't been called in a while. :D