我有下面的javascript函数,当新文档添加到列表中时,它会闪烁链接的bg3次。
这在第一次工作正常,但随后对该函数的调用会导致闪烁变得混乱。它被称为的越多,闪烁行为就越奇怪。
我在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 文档,您不能对背景颜色进行动画处理。 jQuery 建议使用 jQuery.Color 插件。
jQuery animate 文档 - http://api.jquery.com/animate/
j查询颜色插件 - https://github.com/jquery/jquery-color