Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  4] [ 1]  / answers: 1 / hits: 28111  / 15 Years ago, tue, july 21, 2009, 12:00:00

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.



visibility:hidden loads the element, but does not show it.



Why does jQuery use display:none for its show/hide functions instead of switching between visibility:hidden and visibility:visible?


More From » jquery

 Answers
3

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().


[#99088] Thursday, July 16, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mustafaericho

Total Points: 322
Total Questions: 103
Total Answers: 110

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
mustafaericho questions
Mon, May 31, 21, 00:00, 3 Years ago
Sun, May 23, 21, 00:00, 3 Years ago
Sat, Feb 13, 21, 00:00, 3 Years ago
Sat, Jan 2, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
;