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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -