我有一个跨度类:cash_warn。我想用jquery动画改变span的颜色,但是它不起作用。
我现在拥有的:
$('.cash_warn').animate({ color: "#ff8484" }, 500);
另一方面,这确实可以正常工作,但它不会为其设置动画:
$('.cash_warn').css('color',"#ff8484");
html:
<div class=" friends-shadow detailreward3 detailreward" style="position:absolute;
height:71px; width:238px; left: 453px; top: 40px; padding:20px; z-index:99; font:
bold 11px Helvetica, Arial, sans-serif;">
<span style=" color:#fff" class="cash_warn">
text
</span>
<br /> <br />
more text
</div>
知道出了什么问题吗?
最佳答案
除非使用 jQuery color
插件,否则无法设置颜色动画。 (GitHub)
All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color() plugin is used). Property values are treated as a number of pixels unless otherwise specified.
Note: The jQuery UI project extends the .animate() method by allowing some non-numeric styles such as colors to be animated. The project also includes mechanisms for specifying animations through CSS classes rather than individual attributes.
关于jquery动画: change span color not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10567259/