我有一个<div>
其中包含背景图像,<div>
位于HTML中的工具栏内。jquery - 淡入淡出在悬停的背景图像
HTML:
<div id="toolbar">
<div class="image"> </div>
</div>
CSS:
#toolbar .image {
background url('images/logo.png') no-repeat top left;
}
#toolbar .imagehover {
background url('images/logoHover.png') no-repeat top left;
}
当鼠标悬停在#toolbar
我想要的.image
背景图像改变,但使用.fadeOut()
和.fadeIn()
到目前为止,我有:
$("#toolbar").hover(function() {
$(".image").fadeOut("slow");
$(".image").addClass("imagehover");
$(".imagehover").fadeIn("slow");
},
function() {
$(this).removeClass("imagehover");
});
当前标志淡出,悬停标志两次消失。
任何帮助表示赞赏。
您无法更改背景元素的不透明度,这是fadeIn()的作用 - 您可能需要隐藏元素并将其完全放置,然后淡入淡出。 – 2010-03-09 12:00:50