jQuery如何实现hide()和show() [英] How does jQuery implement hide() and show()
问题描述
他们设置 display:none
或 visibility:hidden
?
我很确定 display:none
使元素退出正常流程,而 visibility:hidden
只是隐藏元素,但仍有一个保留的空间。
I'm pretty sure display: none
takes the element out of the normal flow, whilst visibility: hidden
just hides the element but still has a reserved space for it.
我应该下载解压缩的版本并研究它,或有人有一个快速的回答? / p>
Should I just go download the unpacked version and study it or does someone have a quick answer?
推荐答案
它使用 display
。
编辑:从John Sheehan对这个答案的评论,我同意:
And from John Sheehan's comment on this answer, which I agree with:
You should go view the unpacked source anyway just to familiarize yourself with it
编辑2:评论提到使用Firebug来发现正在发生的事情。事实上,我实际上去了jQuery文档,并使用Safari Web Inspector来查看在 hide()
演示中发生了什么,以确保我的答案。
Edit 2: Comments have mentioned using Firebug to discover what is happening. Indeed, I actually went to the jQuery docs and used the Safari Web Inspector to see what happened on the hide()
demo to be sure of my answer.
这篇关于jQuery如何实现hide()和show()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!