I know this has been asked several times but I just don't get it. So here's the case:
$ = jQuery;
var loop = function() {
$('#content').delay(800).css('background-color', "#B24296");
$('#content').delay(1600).css('background-color', "#AEB404");
$('#content').delay(2400).css('background-color', "#04B404");
loop();
}
$(document).ready(function() {
loop();
This setup gives me an "Uncaught RangeError: Maximum call stack size exceeded" I also tried this:
var loop = function() {
$('#content').delay(800).css('background-color', "#B24296", function() {
$('#content').delay(1600).css('background-color', "#AEB404", function() {
$('#content').delay(2400).css('background-color', "#04B404");
});
});
}
$(document).ready(function() {
setInterval(loop,3200);
With this code only the first color change happens but the rest of it won't. So unfortunately none of this does the job of simply changing the background-color from time to time ... Does anyone know a solution or can explain why non of this works?
Edit: Managed to get it to work like this:
function color(t) {
$("div").delay(t*1).queue(function(n) {
$('#green').css('background-color', "#B24296");
n();
});
$("div").delay(t*2).queue(function(n) {
$('#green').css('background-color', "#AEB404"); n();
});
$("div").delay(t*3).queue(function(n) {
$('#green').css('background-color', "#04B404");
n();
});
setTimeout(function() {
color(500);
}, 500);
}
color(500);
.delay()on.css()... it just jumps to the end