我在尝试让我的淡入淡出效果正常工作时遇到了一些困难。我想我把它复杂化了。
我有 4 张图像,但是只有前 2 张需要淡出并在图像悬停时进入(其他 2 张图像与页面上的其他一些功能一起发挥作用)。
我的 HTML 是:
<div class="square">
<div class="imageHolder">
<!--Comment out and uncomment BG image to show transitions on BG images-->
<img class="one" src="image_01.jpg" />
<img class="two" src="image_02.jpg" />
<img class="three" src="image_03.jpg" />
<img class="four" src="image_04.jpg" />
</div>
</div>
图像,二,三,四不显示
JS:
$('.square').mouseover(function () {
$(this).find('img').each(function () {
if ($(this).attr('class') === 'two') {
$(this).fadeIn('slow');
}
if ($(this).attr('class') === 'one') {
$(this).fadeOut('slow');
}
});
});
任何帮助将非常感激。
感谢您的回复。
我试图变得太聪明,它不需要它。有没有办法让淡入和淡出同时发生而不使用插件?