javascript - jquery css背景色 渐进显示
本文介绍了javascript - jquery css背景色 渐进显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
我做一个价格展示 需要根据涨跌显示不同的颜色
.css('background','#C13B3F');
.css('background','#2BA838');
但 这样显示的太生硬 怎么让他显示的柔和一点的变化
解决方案
看了眼btc123 大致懂题主的意思
使用jQ的animate() 如果要改背景色需要用官方的插件jQuery.color.js
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script src="jquery.color.js"></script>
</head>
<body>
<button>1</button>
<p style="background-color:#eee;">2017</p>
</body>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").animate({backgroundColor:'#d43b3b'},"slow")
$("p").animate({backgroundColor:'#eee'},"slow")
});
});
</script>
</html>
这篇关于javascript - jquery css背景色 渐进显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文