Thread: Hide class
View Single Post
Old 10-28-2012, 10:44 AM   PM User | #1
Vraith
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Vraith is an unknown quantity at this point
Hide class

Hello

My assignment is to find all <p> and hide the ones that are <p class="show"> using a For Loop. "show" is supposed to be hidden when loading the page, because im gonna do a < a > that is gonna show them. This is what i have done, and it doesnt work. Did i do something wrong or am i way off here ?

windows.onload = prepareShow;
function prepareShow(){
var fan = document.getElementsByClassName("show");
for (var i = 0; i < fan.length; i++){
if (fan[i].getAttribute("class")=="show"){
fan[i].style.display="none";}
}
}
Vraith is offline   Reply With Quote