[英]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.