我试图在背景最初为 rgba(0,0,0,0)
=> originalColor
的 div 上获得闪烁效果并使其闪烁到 rgba(237,155,0,1)
=> noticeFlashColor
。为此,我正在使用:
var noticeFlashEffect = function (applyTo, originalColor) {
return setInterval(function () {
$(applyTo).animate(
{ 'background-color': noticeFlashColor },
flashTime,
function () {
$(applyTo).animate({ 'background-color': originalColor }, flashTime);
}
);
}, (2 * flashTime));
};
但是,每次我尝试这样做时都会收到此错误:
Uncaught TypeError: Cannot read property '0' of undefined
来自 jQuery-ui 中的这一行:
fx.elem.style[attr] = 'rgb(' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
但更奇怪的是,在调试器中检查后,上述变量似乎都不是 null。
编辑:进一步说明:我正在使用 jquery-ui.1.8.4,动画效果似乎在为 noticeFlashColor
设置动画时有效,但在返回时无效。
最佳答案
看起来这只是 jQuery ui 1.8.4 中的一个问题。我升级到 1.10,它似乎工作正常。
关于javascript - 不透明的 jQuery 动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22441594/