本文实例讲述了jQuery animate()实现背景色渐变效果的处理方法。分享给大家供大家参考,具体如下:
jquery animate函数不能处理背景色渐变,需要使用jquery.color插件
核心代码:
$(function(){
$("#cdiv").animate(
{
backgroundColor:'#FF0000'
},1000
)
})
完整代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>背景色渐变效果</title>
</head>
<body>
<script language="javascript" type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.color.js"></script>
<div id='cdiv' style='width:200px;height:100px;background-color:white'></div>
<script>
$(function(){
$("#cdiv").animate(
{
backgroundColor:'#FF0000'
},1000
)
})
</script>
</body>
</html>
运行效果图如下:
[img]http://files.jb51.net/file_images/article/201703/2017315113226469.gif?2017215113240[/img]
[b]附:[/b][code]jQuery.color.js[/code]插件点击此处[url=http://xiazai.jb51.net/201703/yuanma/jquery.color(jb51.net).rar]
[b]本站下载[/b][/url]。
[b]PS:这里再为大家推荐几款相关的颜色与特效工具供大家参考使用:[/b]
[b]在线特效文字/彩色文字生成工具:
[/b][url=http://tools.jb51.net/aideddesign/colortext]http://tools.jb51.net/aideddesign/colortext[/url]
[b]在线彩虹文字/颜色渐变文字生成工具:
[/b][url=http://tools.jb51.net/aideddesign/txt_caihongzi]http://tools.jb51.net/aideddesign/txt_caihongzi[/url]
[b]在线发光字生成工具:
[/b][url=http://tools.jb51.net/aideddesign/txt_faguangzi]http://tools.jb51.net/aideddesign/txt_faguangzi[/url]
[b]仿古书排版文字竖排转换工具:
[/b][url=http://tools.jb51.net/transcoding/shupai]http://tools.jb51.net/transcoding/shupai[/url]
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/200.htm]jQuery常用插件及用法总结[/url]》、《[url=http://www.1sucai.cn/Special/93.htm]jquery中Ajax用法总结[/url]》、《[url=http://www.1sucai.cn/Special/539.htm]jQuery表格(table)操作技巧汇总[/url]》、《[url=http://www.1sucai.cn/Special/451.htm]jQuery扩展技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/430.htm]jQuery常见经典特效汇总[/url]》及《[url=http://www.1sucai.cn/Special/75.htm]jquery选择器用法总结[/url]》
希望本文所述对大家jQuery程序设计有所帮助。