我可以使用jQuery淡入颜色吗? [英] Can I fade in a color with jQuery?

查看:72
本文介绍了我可以使用jQuery淡入颜色吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个javascript,它可以通过以下功能来更改某些HTML:

I have javascript that changes some HTML with a function like this:

if (correct == "true") {
   $('#ft2').html('Correct');
   $('#ft2').css('color', 'Green')
   $('#ft2').css('border-color', 'Green')
} else {
   $('#ft2').html('Incorrect');
  $('#ft2').css('color', 'Red')
  $('#ft2').css('border-color', 'Red')
}

文本在页面上的变化非常快,我想让它对我的用户来说更好看.有没有一种方法可以使用jQuery淡化颜色?例如,是否在一秒钟的时间内出现了新颜色.

The text changes very quickly on the page and I would like to make it look better for my users. Is there a way that I can use jQuery to fade in the color? For example have the new color appear over the time of one second.

推荐答案

如果要在jquery中设置颜色的动画,则需要一个插件:

If you want to animate color in jquery, you'll need a plugin:

http://plugins.jquery.com/project/color

Resig插件的链接似乎很旧,因此您也可以尝试编写一些其他插件来做相同的事情:

it looks like the link to Resig's plugin is old, so you can also try some of the other plugins that have been written to do the same thing:

http://www.bitstorm.org/jquery/color-animation/

这是Resig原始插件的直接链接:

here's a direct link to Resig's original plugin:

http://plugins.jquery.com/files/jquery.color. js.txt

只需将页面另存为jquery.color.js

Just save the page as jquery.color.js

这篇关于我可以使用jQuery淡入颜色吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆