下面先贴一段源码
function genFx( type, includeWidth ) {
var which,
attrs = { height: type },
i = 0;
// if we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}
if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}
return attrs;
}
上面的代码为jQuery源码,但是看不懂。之后我在执行slide方法时输出操作元素的各个属性
输出的各个值:visibility:visible;height:24px;这两者无论隐藏还是显示都不改变。alert($("#1").next().css('display')); $("#1").nextUntil('#2').slideToggle(1);
display在隐藏时为none 显示时为table-row(我隐藏的是表格)
所以小伙伴们,以后在使用slide方法可以用判断display的值来确定元素是隐藏状态还是显示状态