当我们用animate()函数做动画效果时,这里backgounColor单单用jquery函数库是实现不了的,需要引入 Color Animations 插件(jquery-ui.min.js),下面是一些实例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>animate color annimation</title>
<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<!--<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>-->
<script src="../js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function(){
$(‘button‘).click(function(){
var div=$(‘div‘);
div.animate({top:‘300px‘,backgroundColor:‘#ADFF2F‘},2000);
div.animate({left:‘300px‘,backgroundColor:‘#008B8B‘},‘slow‘);
div.animate({top:‘40px‘,height:‘300px‘,opacity:‘0.5‘},1000);
div.animate({left:‘20px‘,height:‘100px‘,opacity:‘1‘,fontSize:‘40px‘},‘slow‘);
});
});
</script>
</head>
<body>
<button>开始动画</button>
<div style="width: 100px; height: 100px; background-color:#ADFF2F; position: absolute; text-align: center; font-size: 20px;"><p>big</p></div>
</body>
</html>
原文地址:http://blog.csdn.net/navysir8/article/details/45577605