Jquery悬停功能在Opera,Chrome中不起作用



这是我的脚本。但他只在火狐工作。请帮忙!

<script>
    $(document).ready(function(){
         $(".catdiv").hover(function(){
            $(this).animate({"backgroundColor": "#FFD800"}, 300);
          }, function(){
            $(this).animate({"backgroundColor": "#161616"}, 200);
          }); 
    });
</script>

如果你不介意非jQuery(或非Javascript)的解决方案:

.catdiv,
.catdiv:hover {
    transition: background-color 500ms;
    -webkit-transition: background-color 500ms;
    -moz-transition: background-color 500ms;
    -ms-transition: background-color 500ms;
    -o-transition: background-color 500ms;
    background-color: #161616
}
.catdiv {
    background-color: #FFD800;
}

演示:http://jsfiddle.net/L8r6w/1/

你必须使用 jQuery.color 插件来制作背景颜色的动画。jQuery不支持它,因为大多数浏览器现在都本机处理它。

链接: jQuery 颜色

最新更新