jquery - Why doesn't setTimeout work as callback? -
basically, i'm trying fade in #container_swap
on #container
, wait 2 seconds, swap background of #container
, 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) } )
you're calling swapbg
, passing result settimeout
. want pass function instead:
settimeout(swapbg, 2000)
Comments
Post a Comment