gpt4 book ai didi

javascript - jQuery fadeIn() 位于 if 和 else 之间

转载 作者:行者123 更新时间:2023-12-03 06:38:38 24 4
gpt4 key购买 nike

我想在不同的事情发生时加载的不同图像之间淡入淡出。我创建了一些 if, else 规则,并认为我可以使用 fadeIn() 告诉 jQuery 在每个新图像中淡入淡出。但它不起作用,我不知道为什么。我认为这是一个我无法弄清楚的 super 小代码。希望大家能够帮助我!

这是迄今为止我的代码:

if(count == 1){
$('.star').html('<img src="' + stern1 + '">').delay(1000).fadeIn('slow');
} else if (count == 2){
$('.star').html('<img src="' + stern2 + '">').delay(1000).fadeIn('slow');
} else if(count == 3){
$('.star').html('<img src="' + stern3 + '">').delay(1000).fadeIn('slow');
} else if(count == 4){
$('.star').html('<img src="' + stern4 + '">').delay(1000).fadeIn('slow');
} else if(count == 5) {
$('.star').html('<img src="' + stern5 + '">').delay(1000).fadeIn('slow');
} else {
$('.star').html('<img src="' + stern1 + '">').delay(1000).fadeIn('slow');
}

最佳答案

你的错误是:

Insert the content in your html

因此它始终显示内容,您的努力不会像延迟和淡入那样显示。

请尝试以下操作:

$('.star').html('<img src="' + stern1 + '">').hide().delay(1000).fadeIn('slow');

关于javascript - jQuery fadeIn() 位于 if 和 else 之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38075768/

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