gpt4 book ai didi

jquery - 我正在尝试使用 jQuery 进行循环

转载 作者:行者123 更新时间:2023-12-01 07:35:35 25 4
gpt4 key购买 nike

我需要它做的就是一遍又一遍地运行 animateAds 函数。有人可以帮忙吗?这是我的代码:

function animateAds(n) {
$('#ad_1').fadeIn('slow', function (){
$('#ad_1').delay(100).fadeOut('fast', function (){
$('#ad_2').fadeIn('slow');
});
});
};

$(document).ready(function() {
for (n = 0; n < 10; n++) {
animateAds(n);
}
});

最佳答案

<!doctype html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
var i=0;
function animateAds() {
if(i==9){return;}
$('#ad_2').fadeOut('fast',function(){
$('#ad_1').fadeIn('slow', function (){
$('#ad_1').delay(100).fadeOut('fast', function (){
$('#ad_2').fadeIn('slow', function(){i++;animateAds();});
});
});
});
};
$(document).ready(function() {
animateAds();
});
</script>
</head>
<body>


<img id='ad_1' style='display:none' src='http://sstatic.net/so/img/logo.png'>
<br>

<img id='ad_2' src='http://sstatic.net/so/img/logo.png'>

我不确定这是否理想,但它可以作为一个独立的页面。这就是你想要做的吗?

关于jquery - 我正在尝试使用 jQuery 进行循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2233218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com