jquery – foverOut / fade在悬停时的背景图像

我有一个< div>其中包含背景图片,< div>坐在HTML的工具栏中.

HTML:

<div id="toolbar">
   <div class="image">&nbsp;</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");
});

目前徽标淡出,悬停徽标淡出两次.

任何帮助赞赏.

解决方法

//Use the fad in out callback 
$("#toolbar").hover(function () {
    $(".image").fadeOut("slow",function () {
        $(this).addClass("imagehover").fadeIn("slow",function () {
            $(this).removeClass("imagehover");
        });
    });

});

//or you can use animate 
$("#toolbar").animate({
    "class": "imagehover"
},"slow",'easein',function () {
    //do what every you want   
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...