Tag: timed events

jquery如何每5秒触发同一事件

我已经建立了一个左右滚动的简单旋转木马。 现在我想每5秒自动滚动一次。 这是我的代码: function carousel(){ $j(‘#carousel_ul li:first’).before($j(‘#carousel_ul li:last’)); $j(‘#right_scroll img’).click(function(){ var item_width = $j(‘#carousel_ul li’).outerWidth() + 10; var left_indent = parseInt($j(‘#carousel_ul’).css(‘left’)) – item_width; $j(‘#carousel_ul:not(:animated)’).animate({‘left’ : left_indent},800, ‘easeOutExpo’,function(){ $j(‘#carousel_ul li:last’).after($j(‘#carousel_ul li:first’)); $j(‘#carousel_ul’).css({‘left’ : ‘-750px’}); }); }); $j(‘#left_scroll img’).click(function(){ var item_width = $j(‘#carousel_ul li’).outerWidth() + 10; var left_indent = parseInt($j(‘#carousel_ul’).css(‘left’)) + item_width; $j(‘#carousel_ul:not(:animated)’).animate({‘left’ : left_indent},800, ‘easeOutExpo’,function(){ $j(‘#carousel_ul […]