jquery里show(0)的问题?

clipboard.png

这段代码如果我的show()里面不加参数0,他就不会延迟800ms后显示,而是始终显示(hide()无效?);而加了0才能延迟800ms后显示,这是为什么呢,不是默认show()的参数就是0吗?而且就算不是0也不能一直显示啊???

阅读 2.4k
2 个回答

看下源码哦,$.fn.show:

function ( speed, easing, callback ) {
    return speed == null || typeof speed === "boolean" ?
        cssFn.apply( this, arguments ) :
        this.animate( genFx( name, true ), speed, easing, callback );
}

可以看到不传speed直接就显示(改css)啦,传入0才会走整个animate的机制,并没有把speed默认为0哦。

.show( [duration ] [, complete ] )
duration (default: 400)
Type: Number or String
A string or number determining how long the animation will run.
complete
Type: Function()
A function to call once the animation is complete, called once per matched element.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题