JavaScript

超轻量级php框架startmvc

jQuery animate()实现背景色渐变效果的处理方法【使用jQuery.color.js插件】

更新时间:2020-04-30 01:42:01 作者:startmvc
本文实例讲述了jQueryanimate()实现背景色渐变效果的处理方法。分享给大家供大家参考,具体

本文实例讲述了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>

运行效果图如下:

 

附:jQuery.color.js插件点击此处本站下载

PS:这里再为大家推荐几款相关的颜色与特效工具供大家参考使用:

在线特效文字/彩色文字生成工具: http://tools.jb51.net/aideddesign/colortext

在线彩虹文字/颜色渐变文字生成工具: http://tools.jb51.net/aideddesign/txt_caihongzi

在线发光字生成工具: http://tools.jb51.net/aideddesign/txt_faguangzi

仿古书排版文字竖排转换工具: http://tools.jb51.net/transcoding/shupai

jQuery animate() 背景色 渐变 jQuery.color.js 插件