【发布时间】: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');
}
}
【问题讨论】:
-
你能发布一些与此相关的 html 吗?
-
查看其他问题(可能重复?)stackoverflow.com/questions/190560/…
标签: jquery css jquery-animate background-color