jQuery – 使用animation()函数重新创建slideDown()效果?

我怎样才能做到这一点? :D

解决方法

将“height”,“marginTop”,“marginBottom”,“paddingTop”和“paddingBottom”设为“显示”.

例如:

$(...).animate({
    "height": "show","marginTop": "show","marginBottom": "show","paddingTop": "show","paddingBottom": "show"
});

来源:jQuery源代码

fxAttrs = [
    // height animations
    [ "height","marginTop","marginBottom","paddingTop","paddingBottom" ],// width animations
    [ "width","marginLeft","marginRight","paddingLeft","paddingRight" ],// opacity animations
    [ "opacity" ]
];
...

jQuery.each({
    slideDown: genFx("show",1),slideUp: genFx("hide",slidetoggle: genFx("toggle",fadeIn: { opacity: "show" },fadeOut: { opacity: "hide" }
},function( name,props ) {
    jQuery.fn[ name ] = function( speed,callback ) {
        return this.animate( props,speed,callback );
    };
});
...

function genFx( type,num ) {
    var obj = {};

    jQuery.each( fxAttrs.concat.apply([],fxAttrs.slice(0,num)),function() {
        obj[ this ] = type;
    });

    return obj;
}

相关文章

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