jquery – 切换div与宽松

前端之家收集整理的这篇文章主要介绍了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

猜你在找的jQuery相关文章