Change background from time (Problem)

0

I need to change the background from a certain time, but the site was already half done so the background loading is being done in jquery with this function

    $(".intro").backstretch("img/" + images[Math.floor(Math.random() * 
    images.length)] ,   { centeredX:true, centeredY:true});

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 does not work? ah 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 somebody knows why not thank you, obs: if it is to do by css calling a class and passing the schedule to call another I can, but I want it that way, because it is already stylized, obs does not go into this function.

    
asked by anonymous 28.03.2017 / 16:22

1 answer

0

I did it, it was my mistake, I'm sorry, I already had a load on it so I think it was in conflict, sorry anyway.

    
28.03.2017 / 16:34