【问题标题】:jQuery backgroundColor animation weirdnessjQuery背景颜色动画怪异
【发布时间】:2012-12-07 05:06:30
【问题描述】:

我有以下 javascript 函数,当一个新文档添加到列表中时,它会闪烁链接的 bg 3 次。

这第一次运行良好,但随后调用该函数会导致闪烁变得混乱。越叫越怪异闪烁的行为。

我在 IE8 和最新版本的 Chrome 中看到了相同的效果。

var highlightNew = function (control) {
    var item = $('li.new-document a.document-link', control);
    if (item.length > 0) {
        var highlightColor = '#ffa500';
        item.stop()
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow')
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow')
            .animate({ backgroundColor: highlightColor }, 'slow')
            .animate({ backgroundColor: 'transparent' }, 'slow');
    }
}

【问题讨论】:

标签: jquery css jquery-animate background-color


【解决方案1】:

你有这个插件吗?

根据 jQuery 文档,您不能为背景颜色设置动画。 jQuery 建议为此使用 jQuery.Color 插件。

jQuery 动画文档 - http://api.jquery.com/animate/

jQuery 颜色插件 - https://github.com/jquery/jquery-color

【讨论】:

    猜你喜欢
    • 2023-03-11
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    • 2010-11-20
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    • 2020-11-04
    相关资源
    最近更新 更多