jQuery:如何淡出类之间? [英] jQuery: how to fade between classes?

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

问题描述

我需要能够在类之间淡入,并无缝地转换应用于元素及其子元素的任何和所有样式。如何使用jQuery做到这一点?我知道如何添加/删除类,但是不同于两种截然不同的颜色之间的一个不错的转换。

I need to be able to fade between classes and seamlessly transition any and all styles being applied to the element and its children. How can this be done using jQuery? I know how to add/remove classes but that is not the same as a nice transition between two drastically different colors.

推荐答案

jQuery UI有一个toggleClass函数,其参数持续时间为:

jQuery UI has a toggleClass function that has an argument for duration:

http:// jqueryui.com/demos/toggleClass/

例如,我在我的一个网站上执行此操作(淡入/退出 light class and fade / in out the dark class):

For example, I do this on one of my sites (fade in/out the light class and fade/in out the dark class):

$('body').toggleClass('light', 250).toggleClass('dark', 250);

这篇关于jQuery:如何淡出类之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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