微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – 切换div与宽松

我有一个链接,当点击这个我想要一个div放宽,然后再次点击链接,它应该关闭div,放宽…

我看过jQuery缓解插件,但是它不适用于jQuery 1.5.1?有什么想法可以做什么,怎么办?

现在我只有一个slidetoggle函数,没有缓解?

$('.open-mypage').click(function () {
    $('#mypage-info').slidetoggle('2000',function () {
        // Animation complete.
    });
});

解决方法

jQuery slideToggle() documentation说:

.slidetoggle( [ duration ],[ easing ],[ callback ] ) (version added: 1.4.3)

duration A string or number determining how long the animation will run.

easing A string indicating which easing function to use for the transition.

callback A function to call once the animation is complete.

您可以看到,有一个名为[easing]的参数,其描述是:

Easing

As of jQuery 1.4.3,an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default,called swing,and one that progresses at a constant pace,called linear. More easing functions are available with the use of plug-ins,most notably the jQuery UI suite.

所以你有两个选择:

1)您可以使用一个可用的缓存:

$('.open-mypage').click(function () {
    $('#mypage-info').slidetoggle('2000',"swing / linear",function () {
        // Animation complete.
    });
});

2)您的页面中包含jQuery UI并使用one of its 32 easings

$('.open-mypage').click(function () {
    $('#mypage-info').slidetoggle('2000',"eaSEOutBounce",function () {
        // Animation complete.
    });
});

You can see a jsFiddle example here

原文地址:https://www.jb51.cc/jquery/176659.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐