我希望我的文字从白色褪色为黑色,背景颜色同时从黑色变为白色,有什么想法吗?
发布于 2010-09-04 16:36:19
在jQuery中,默认情况下可以使用以下命令为文本设置动画颜色:
$('#element').animate({ color: 'red' }, 1500);
但是背景动画不能在默认情况下完成,需要一个插件(链接如下)。
jQuery:http://www.jquery.com/
彩色插件:http://plugins.jquery.com/project/color
Enjoi ^.^
发布于 2010-09-04 16:42:57
这可以通过jQuery color plugin很容易地实现
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function() {
$('#foo').animate({
backgroundColor: '#fff',
color: '#000'
}, 'slow');
});
</script>
</head>
<body>
<div id="foo" style="background-color: black;">Some Text</div>
</body>
</html>
在action here中查看它。
https://stackoverflow.com/questions/3641476
复制相似问题