用jquery褪色? [英] Fading colors with jquery?

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

问题描述

我使用jquery进行常规颜色更改,但我想拥有它,因此它具有平滑的颜色变化。此时,代码会在悬停时更改链接的颜色,然后在删除鼠标时将其删除。我看过一个教程,但它没有解释它,它看起来不像我当前的代码。这就是目前的情况:

I have a regular color change using jquery, but I'd like to have it so it has a smooth color change. At the moment, the code changes the color of a link on hover and then removes it when the mouse is removes. I have seen one tutorial but it doesn't explain it and it does not look like my current code. This is what it looks like at the moment:

$(document).ready(function() {
$("#link1,#link2,#link3").hover(function() {
$(this).addClass("red");
},function(){
 $(this).removeClass("red");   }); });

提前致谢

推荐答案

您可以使用 .animate() ,如下所示:

You'd use .animate(), like this:

$(document).ready(function() {
  $("#link1,#link2,#link3").hover(function() {
    $(this).stop().animate({ color: "#990000" });
  },function(){
    $(this).stop().animate({ color: "#FFFFFF" });
  }); 
});

注意,你需要颜色插件 jQuery UI 包含用于颜色动画工作。

Note though, you need either the color plugin, or jQuery UI included for color animations to work.

这篇关于用jquery褪色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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