【问题标题】:Hover animation with js not working带有js的悬停动画不起作用
【发布时间】:2012-11-01 06:29:16
【问题描述】:

悬停时背景颜色应该有动画,不悬停时停止。为什么它不起作用的任何线索? JSLint 有效。

var pixColors = {
init: function() {
   function pixelColors(){
       var color = '#'+(Math.random()*0xCCCCCC<<0).toString(16);
    $('.colorAnim').animate({
    backgroundColor: color
}, 1000, pixelColors);
}
$('.colorAnim').hover(
function(){
pixelColors();
},
function() {
$('.colorAnim').stop(true);
});
}
}
$(document).ready(function() {
    pixColors.init();
});

http://jsfiddle.net/Commandrea/WVU24/1/

【问题讨论】:

    标签: javascript animation hover


    【解决方案1】:

    在 jQuery 中默认情况下不能为颜色设置动画。您需要jQuery Color 或 jQuery UI。

    【讨论】:

    • 天哪。我完全忽略了这一点!感谢您为我节省了更多浪费的时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2021-12-21
    • 2014-09-07
    • 2019-09-14
    • 2013-06-27
    • 1970-01-01
    相关资源
    最近更新 更多