前端开发入门到进阶第三集【定时器】


var mi = 0;
var timer = setTimeout(handler,1000);
function handler(){
if(mi == 5){
$(".item-desc .desc-part").empty();
clearTimeout(timer);
return; 你没有在clearTimeout后return函数的结果,导致代码继续运行。 https://zhidao.baidu.com/question/1542396607093854467.html
}
mi ++ ;
setTimeout(handler,1000);
}

参考:https://www.jquery123.com/fadeOut/

$(".item-desc .desc-part").fadeOut(5000,function(){
$(".item-desc .desc-part").empty();
});

猜你喜欢

转载自www.cnblogs.com/lirenhe/p/11049577.html