setTimeout runs only once?

前端 未结 8 1663
醉酒成梦
醉酒成梦 2020-12-10 10:43
function slide()
{
    if($(\'.current\').is(\':last-child\')){
        $(\'.current\').removeClass(\'.current\');
        $(\'#imgholder\').first().addClass(\'.curr         


        
8条回答
  •  情话喂你
    2020-12-10 11:02

    use setTimeout with recursion (endless loop)

    If you want to keep the exact space between each function call use setTimeout instead setInterval. setInterval can overlap at some point and this is often not expected behavior.

    (function test(){
      setTimeout(function(){
        console.log(1);
        testt();
      }, 2000)
    })()
    

提交回复
热议问题