0
I need to change the background from a certain time, but the site was already half done so the loading of the background is being done in jquery with this function
$(".intro").backstretch("img/" + images[Math.floor(Math.random() *
images.length)] , { centeredX:true, centeredY:true});
So I basically tried to do this
$(window).on('load', function () {
var today = new Date()
var curHr = today.getHours()
/*HORARIO Menor que 12 horas*/
if (curHr < 12) {
var images = ['london.png'];
$(".intro").backstretch("img/" + images[Math.floor(Math.random() *
images.length)] , { centeredX:true, centeredY:true});
}
else{
var images = ['outra imagem'];
$(".intro").backstretch("img/" + images[Math.floor(Math.random() *
images.length)] , { centeredX:true, centeredY:true});
}
}
Does anyone know why it doesn’t work? oh and if you need the class . intro is here
.intro {
display: table;
width: 100%;
color: #fff;
text-shadow: 0 1px 3px rgba(0,0,0,.2);
height: 100%;
background: #000 url(../img/5.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
If anyone knows why it doesn’t work thank you, Obs: if it’s to do by css calling one class and passing the time to call another I can, but I want this way, because it is already stylized, Bs does not enter into this function.
Remove the css background..
– Marlysson
removed, but nothing...
– Anderson Henrique
I guess it would just be a picture for a while, right? If you do not need Random, just set date frame by period ( in some var ) and use the already created function: $(". intro"). backstretch("img/"+imagem_selected, { centeredX:true, centeredY:true});
– Marlysson