shmoyko
04-26-2010, 05:25 PM
Hello people,
I have a site http://insearchofsound.com/index.php
and I would like to change the background indefinitely every 10 seconds.
Here's the code
$(document).ready(function() {
//image index
var ii = 0;
//timer
var t;
//list of images
var imgs = ["bg1.jpg","bg2.jpg","bg3.jpg"];
loopBG(imgs,ii);
});
function loopBG(imgs,ii) {
$("pagewrapper").css("background-image","url(backgrounds/" + imgs[ii] + ")");
ii++;
if (ii == imgs.length) {
ii = 0;
}
t = setTimeout(loopBG(imgs,ii), 10000);
}
Two problems with this code: first, the backgrounds don't change at 10 second intervals (they don't change at all) and second, I get the "too many iterations" error after a few seconds.
Any solutions?
Many thanks
Shmoyko
I have a site http://insearchofsound.com/index.php
and I would like to change the background indefinitely every 10 seconds.
Here's the code
$(document).ready(function() {
//image index
var ii = 0;
//timer
var t;
//list of images
var imgs = ["bg1.jpg","bg2.jpg","bg3.jpg"];
loopBG(imgs,ii);
});
function loopBG(imgs,ii) {
$("pagewrapper").css("background-image","url(backgrounds/" + imgs[ii] + ")");
ii++;
if (ii == imgs.length) {
ii = 0;
}
t = setTimeout(loopBG(imgs,ii), 10000);
}
Two problems with this code: first, the backgrounds don't change at 10 second intervals (they don't change at all) and second, I get the "too many iterations" error after a few seconds.
Any solutions?
Many thanks
Shmoyko