[英]Animating to another background-color, then back again
我正試圖讓我的白色背景閃爍綠光。 目前我有這個代碼,它變成綠色:
$( "#modal_newmessage" ).animate({
backgroundColor: "#8bed7e"
}, 500 );
但是,我無法想象如何讓它在同一個動畫中再次變白。 我該怎么做呢?
您可以鏈接另一個.animate()
調用,因為動畫將在fx
隊列中排隊。
$("#modal_newmessage").animate({
backgroundColor: "#8bed7e"
}, 500).animate({
backgroundColor: "#fff"
}, 500);
請記住,大多數jQuery函數都是可鏈接的,無需兩次調用$("#modal_newmessage")
。
這應該工作:
$( "#modal_newmessage" ).animate({
backgroundColor: "#8bed7e"
}, 500, function() {
$( "#modal_newmessage" ).animate({ backgroundColor: "#fff" });
} );
試試這個:
$(function() {
$( "#modal_newmessage" ).animate({
backgroundColor: "#aa0000",
color: "#fff",
width: 500
}, 1000 ).animate({
backgroundColor: "#fff",
color: "#000",
width: 240
}, 1000 );
});
對於動畫背景顏色,您需要jQuery ui
用於顏色動畫。
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.