jQuery的 - 文本颜色淡入 [英] jQuery - text color fade in

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

问题描述

我无法找到一个简单的解决这个问题。

I can't find a simple solution to this problem.

我想在一些文本的颜色变化褪色时,有从一个按钮点击一个错误。

I am trying to fade in a color change for some text when there is an error from a button click.

if (document.getElementById("username").value == ""){ //First Name      
    $("#login_error").text("Please enetr a username!").css('color', '#FF0000');     
    $("#username_label").css('color', '#FF0000');fadeIn(3000);
}

我能得到的颜色改变,但它是即时的。我希望得到的颜色的变化而慢慢淡化英寸

I can get the color to change but it is instant. I am wanting to get the change of colour to fade in slowly.

谢谢你们!

推荐答案

如果您添加jQuery UI的,他们增加了支持彩色动画。

If you add jQuery UI, they added support for color animations.

http://jqueryui.com/demos/animate/ 了解详情。

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

  <script>
  $(document).ready(function(){
    $(".block").toggle(function() {
      $(this).animate({ color: "#FF0000" }, 1000);
    },function() {
      $(this).animate({ color: "#000000" }, 1000);
    });
  });
  </script>

更新:的jQuery现在提供了一个颜色插件只启用此功能没有包括整个的jQuery-UI库。

Update: jQuery now offers a color plugin to enable only this feature without including the entire jQuery-UI library.

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

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