簡體   English   中英

setInterval問題

[英]Problem with setInterval

此功能的間隔將不起作用。 我輸入5000、1000或300000都沒關系。

我究竟做錯了什么?

$(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);
});


});

考慮到您要間隔十秒鍾,您應該等待更長的時間...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM