【发布时间】:2011-05-11 16:06:21
【问题描述】:
我这里有 jQuery 淡入淡出:http://dougie.thewestharbour.com/
当您将鼠标悬停在 .main-overlay div 上时,我希望它淡出,然后当您将鼠标移开时,我希望它淡入。
但是,您现在可以看到它只是在闪烁。我猜这是因为 div 消失了,所以当它淡出时它被视为 mouseout 但我不知道如何解决它。
这是我的 javascript:
$(document).ready(function () {
$('.main-overlay').hover(
//Mouseover, fadeIn the hidden hover class
function() {
$(this).fadeOut('1000');
},
//Mouseout, fadeOut the hover class
function() {
$(this).fadeIn('1000');
}).click (function () {
//Add selected class if user clicked on it
$(this).addClass('selected');
});
});
这是覆盖 div 附加到的项目之一:
<li><div class="main-overlay"></div><span class="caption">The store front</span><img src="http://dougie.thewestharbour.com/wp-content/uploads/store-front.jpg" alt="store front" title="store-front" width="730" height="360" class="alignnone size-full wp-image-98" /></li>
谢谢,
韦德
【问题讨论】:
标签: jquery hover fadein fade fadeout