jQuery backgroundColor动画怪异

时间:2012-12-06 20:54:59

标签: jquery css jquery-animate background-color

我将以下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');
    }
}

1 个答案:

答案 0 :(得分:0)

你有插件吗?

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

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

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

相关问题