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

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...