Reputation: 2923
Basically, I'm trying to fade in #container_swap
over #container
, wait two seconds, then swap the background of #container
and finally fade #container_swap
out.
function swapBg(){
$('#container').css('background-image',newBg)
$('#container_swap').hide();
}
$(
function(){
$('#container_swap')
.css('background-image',newBg)
.fadeIn(2000)
,setTimeout(swapBg(), 2000)
}
)
Upvotes: 0
Views: 35
Reputation: 298146
You're calling swapBg
and passing its result to setTimeout
. You want to pass the function instead:
setTimeout(swapBg, 2000)
Upvotes: 2