如何在jQuery动画中更改文本颜色? [英] how to change text color in jquery animate?
本文介绍了如何在jQuery动画中更改文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对jquery非常陌生.我正在尝试使用jani动画来更改文本颜色.但是我的代码无法正常工作.请任何人帮助我
I am very new to jquery. I am trying to change text color using jquery animate. But my code is not working. please anyone help me
<script>
$(p).hover(function(){
$(this).animate({"color":"red"})
})
</script>
推荐答案
不使用任何其他插件:我知道这个问题现在已经很老了,但这是为了帮助仍在寻找解决方案的任何人...这是一种解决方法需要任何其他插件.
Without using any additional plugin: I know this question is pretty old now but this is to help anyone still looking for a solution... here is a workaround without the need of any additional plugin.
jQuery css更改颜色:
jQuery css to change the color:
$("p").hover(function(){
$(this).css("color","red");
})
和CSS过渡可在颜色变化时复制动画效果:
and CSS transition to replicate the animation effect when the color changes:
p {
color: black;
-webkit-transition: color 0.4s ease;
-moz-transition: color 0.4s ease;
-o-transition: color 0.4s ease;
transition: color 0.4s ease;
}
这篇关于如何在jQuery动画中更改文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文