2011-04-16 61 views
0

此功能的時間間隔不起作用。不要緊,如果我投入5000,1000或300000.setInterval問題

我做錯了什麼?

$(window).load(function(){ 

var $slide_container = $('#j1-f'), 
the_interval = function(){ 

    var $children_of_container = $slide_container.children(), 
    $first_child_of_container = $children_of_container.eq(0), 
    $width_of_first_child = $first_child_of_container.width(); 

    //since the margin wont be fully deleted if I put it in the function below, I have to delete margin of all children here 
    $children_of_container.css('marginLeft','0'); 

    //move child to the left and then append it to the end of div 
    $first_child_of_container.animate({marginLeft: -$width_of_first_child},1000,function(){ 
     $(this).appendTo($slide_container); 
    }); 

}, 
j3i = setInterval(the_interval,10000); 

//pause interval 
$slide_container.mouseover(function(){ 
clearInterval(j3i); 
}); 

//return interval 
$slide_container.mouseleave(function(){ 
setInterval(the_interval,10000); 
}); 


}); 
+0

問題就解決了。 – Hakan 2011-04-16 10:50:11

回答

0

考慮到要撥打十秒的間隔,你應該等待的時間長一點......

+0

發現問題上面的代碼工作。有些名字被複制到我的JS中...對不起。 – Hakan 2011-04-16 10:49:48