我的功能看起來像jQuery的動畫問題
$.fn.animateHighlight = function(highlightColor, originalColor, type, duration) {
var highlightBg = highlightColor || "#FFFF9C";
var animateMs = 500;
var animateVal1 = {};
animateVal1[type] = highlightColor;
var animateVal2 = {};
animateVal2[type] = originalColor;
this.stop().animate(animateVal1, animateMs).delay(duration).animate(animateVal2, animateMs);
};
調用此類似
$("#variants").animateHighlight("red", "#9c9c9c", "borderColor", 3000);
的問題是,
這是字段集
的默認邊框顏色這是動畫色彩
後,我知道,動畫增加了額外的風格屬性,元素。我想要做的是,返回原始字段集邊框顏色(刪除樣式屬性將返回原始邊框顏色)。
試過的功能最後一行改成這樣
this.stop().animate(animateVal1, animateMs).delay(duration).animate(animateVal2, animateMs).removeAttribute('style');
動畫甚至沒有開始。
如何在動畫後動畫並重置回原始版本?
我可以直接和動畫重置?我的意思是不使用第二種顏色,而是直接使用原始狀態? – heron 2012-02-24 05:46:28
不知道,試着將邊框顏色設置爲透明,看看它是否有效,你可能不得不使用rgba顏色。 – adeneo 2012-02-24 06:04:31