0
I need to change the class of some elements after 3 seconds starting to load the site, I want to do this but I can’t, I was trying with SetTimeout
but I can’t manipulate the question of seconds and I couldn’t find a solution via Google.
I want the site loads with the div in class .oculto
and after 3 seconds she goes to class .visivel
Does anyone know of any solution, please?
Follow Example: HTML
<div class="oculto"></div>
CSS
.oculto{opacity:"0"}
.visivel{opacity:"1";width:100%;height:10%;background-color:#cccccc;}
It worked but in only 1 element, I applied in 1 div and 2 img and only in the div this working, the other item the class is still hidden.
– Clayton Furlanetto
It didn’t work on several elements, only on one, the solution was to create more classes like occult 1 Occult 2 Occult 3 and create tbm 3
setTimeout
changing to the visible class, I don’t know if it would be the right one, but it worked. Thank you @– Clayton Furlanetto
@Claytonfurlanetto uses the same class for everyone. I added this variant to the answer.
– Sergio
didn’t work out this doing the opposite in 3s this disappearing all item with class
.oculto
I did it that way, it’s right?setTimeout(function(){
 var ocultos = document.querySelectorAll('.oculto');
for (var i = 0; i < ocultos.length; i++){
 ocultos[i].classList.add('.visivel');
};
},4 * 1000);
– Clayton Furlanetto
@Exact Claytonfurlanetto. The code I put in was to put inside the
setTimeout
as you did.– Sergio
It didn’t really work out, but otherwise it worked, so I’ll leave it at that msm. vlw.
– Clayton Furlanetto