Javascript jQuery fadeIn()fadeOut()的行为类似于show()和hide()
所以我有一个jQuery代码,我想把它悬停在某个图像上,淡出该图像,淡出另一个处于绝对位置的图像 问题在于这些函数并没有褪色,相反,它们只是显示和隐藏图像 HTML代码Javascript jQuery fadeIn()fadeOut()的行为类似于show()和hide(),javascript,jquery,fadein,fadeout,Javascript,Jquery,Fadein,Fadeout,所以我有一个jQuery代码,我想把它悬停在某个图像上,淡出该图像,淡出另一个处于绝对位置的图像 问题在于这些函数并没有褪色,相反,它们只是显示和隐藏图像 HTML代码 <div class="row"> <div class="col"> <img class="image-without-color"> <img class="image-with-color"> </div> <div class
<div class="row">
<div class="col">
<img class="image-without-color">
<img class="image-with-color">
</div>
<div class="col">
<img class="image-without-color">
<img class="image-with-color">
</div>
</div>
谢谢大家! 嗯。我自由创作了一把小提琴
$(".partner-logo-container").hover(function(){
$(".image-without-color").fadeOut(3000, function(){
$(".image-with-color").fadeIn(3000)
});
});
HTML
对我来说似乎很好?你能具体说明你那边出了什么问题吗
你好,克里斯好的,我感到惭愧。浏览器(Chrome)出现了某种问题。我重新启动,它开始工作。谢谢你们所有人的精彩解决方案 只是为了帮助别人。Uou还应在淡出之前添加停止()。这样,它将停止上一个正在运行的动画 像这样:
$('.partner-logo-container').hover(
function(){
$(".image-without-color", this).fadeOut(250);
$(".image-with-color", this).fadeIn(250);
},
function(){
$(".image-with-color", this).fadeOut(250);
$(".image-without-color", this).fadeIn(250);
}
);
$('.partner-logo-container').hover(
function(){
$(".image-without-color", this).stop().fadeOut(250);
$(".image-with-color", this).stop().fadeIn(250);
},
function(){
$(".image-with-color", this).stop().fadeOut(250);
$(".image-without-color", this).stop().fadeIn(250);
}
);
你能做一把小提琴或类似的东西,这样我们就能知道出了什么问题吗?
。淡出和。淡出和淡出从来都不能很好地配合。尝试在一个元素上使用.fadeIn
,在第二个元素上使用.hide
。您能用脚本将相关HTML添加到代码段以演示问题吗?@koby我尝试了您的方法,但没有成功。我开始想,也许我这里有冲突。@Fran我马上就来!这将隐藏
/显示
元素,而不是淡出
/淡出
?只需用“淡出”代替“隐藏”,用“淡出”代替“显示”,而这段代码可以回答问题,提供有关如何和/或为什么解决问题的额外上下文,就能提高答案的长期价值。谢谢@kris。也许我的代码有冲突。我会试着调试它!
$('.partner-logo-container').hover(function(){
$(".image-without-color", this).fadeOut(250);
$(".image-with-color", this).fadeIn(250);
}, function(){
$(".image-with-color", this).fadeOut(250);
$(".image-without-color", this).fadeIn(250);
}
);
$('.partner-logo-container').hover(
function(){
$(".image-without-color", this).stop().fadeOut(250);
$(".image-with-color", this).stop().fadeIn(250);
},
function(){
$(".image-with-color", this).stop().fadeOut(250);
$(".image-without-color", this).stop().fadeIn(250);
}
);