简体   繁体   中英

Problem with setInterval

The interval of this function will not work. Doesn't matter if I put in 5000, 1000 or 300000.

What am I doing wrong?

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


});

考虑到您要间隔十秒钟,您应该等待更长的时间...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM