ToggleClass动画jQuery? [英] ToggleClass animate jQuery?

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

问题描述

我的网站上有一个部分,当用户点击我希望它展开时,我正在使用jQuery的 toggleClass ...

I have a section on my website that when a user clicks I would like it to expand, I'm using the jQuery's toggleClass for this...

expandable: function(e) {
    e.preventDefault();
    $(this).closest('article').toggleClass('expanded', 1000);
}

这个工作正常,只是我想以某种方式为它制作动画。在Chrome中,我的文章慢慢增长到新的大小,只有在Firefox中,它才能立即调整自己的大小而不使用动画,是否有办法让这种动画变成动画?

This is working fine, only I'd like to somehow animate it. In chrome my article slowly grows to the new size, only in Firefox it 'instantly' resizes itself with no animation, is there a way to have this animate?

推荐答案

jQuery UI扩展了jQuery本地 toggleClass 参数:持续时间

jQuery UI extends the jQuery native toggleClass to take a second optional parameter: duration

toggleClass( class, [duration] )

Google文件+ DEMO

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

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