gpt4 book ai didi

jquery动画: change span color not working

转载 作者:行者123 更新时间:2023-12-01 06:54:32 25 4
gpt4 key购买 nike

我有一个跨度类: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.

Source

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com