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

后端 未结 5 1222
野的像风
野的像风 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:45

    visibility: hidden makes an element invisible but does not remove it from the layout of the page. It leaves an empty box where the element was. display: none removes it from the layout so it doesn't take up any space on the page, which is usually what people want when they hide something.

提交回复
热议问题