var init_speed = (child_width + this_width) / step_len * 1000; // 滚动动画 function scroll_run(continue_speed) { var speed = (continue_speed == undefined ? init_speed : continue_speed); child.animate({ left: -child_width }, speed, "linear", function() { if($('.rech_dm_warp').length > 0){ $.post('/?c=ajax&a=clearcookie&cname=rech_dm'); } $('.rech_dm_warp').remove(); // 清空充值数据cookie scroll_run(); }); } // 鼠标动作 child.on({ mouseenter: function() { var current_left = $(this).position().left; $(this).stop(); continue_speed = (-(-child_width - current_left) / step_len) * 1000; }, mouseleave: function() { scroll_run(continue_speed); continue_speed = undefined; } }); // 启动滚动 scroll_run(); };