jQuery中两个类之间的褪色 [英] Fading between two classes in jquery

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

问题描述

我希望能够淡出这堂课

<h2 class="care-home-fees"><a title="Care Home Fees" href="#">Text</a></h2>

然后淡入

<h2 class="care-home-fees-over"><a title="Care Home Fees" href="#">Text</a></h2>

请注意,有两张单独的图片

Notice there are two separate images

这是我当前的标记,似乎不起作用

Here is my current markup which doesnt seem to work

$(document).ready(function(){  

$("h2.care-home-fees").hover( 
  function () {
    $(this).addClass("care-home-fees-over");
  },
  function () {
    $(this).removeClass("care-home-fees");
  }
);  

});

以及在进行任何更改之前打印的按钮

and the button printed before any change

<h2 class="care-home-fees"><a title="Care Home Fees" href="#">Text</a></h2>

推荐答案

您可能希望使用.animate()而不是.addClass().removeClass().

You might want .animate() instead of .addClass() or .removeClass().

您要在CSS类中使用的是JQuery UI.

What you want to do with CSS classes is in JQuery UI.

http://api.jquery.com/animate/

这篇关于jQuery中两个类之间的褪色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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