Reputation: 15
i have code
function smena(){
$('.wrapper').animate({opacity:0},2500,function(){
setTimeout ($('.wrapper').animate({opacity:1},2500),5000)
});
}
$(document).ready(function(){
setInterval('smena();',10000);
});
why me animaation jump? i want just change bg for my div "wrapper".
Upvotes: 0
Views: 755
Reputation: 659
Basically you're not passing the functions around correctly for setTimeout. You're actually passing the result of "$('.wrapper').animate({opacity:1},2500)" to the setTimeout, not the action itself. This is probably what you want:
function smena(){
$('.wrapper').animate({opacity:0},2500,function(){
setTimeout (function() {
$('.wrapper').animate({opacity:1},2500)
},5000)
});
}
$(document).ready(function() {
setInterval(smena, 10000);
});
Upvotes: 2