Why does jQuery show/hide use display:none instead of visibility:hidden?

后端 未结 5 1217
野的像风
野的像风 2020-12-13 12:14

display:none means that the element isn\'t rendered as part of the DOM, so it\'s not loaded until the display property changes to something else.

5条回答
  •  独厮守ぢ
    2020-12-13 12:28

    Because in display:none, the element, for all purposes, ceases to exist -- it doesn't occupy any space. However, in visibility:hidden, it's as if you had just added opacity:0 to the element -- it occupies the same amount of space but just acts invisible.

    The jQuery creators probably thought the former would be a better fit for .hide().

提交回复
热议问题