jQuery fadeOut without display none?
You can use .animate()
on the opacity
directly:
$(".selector").animate({ opacity: 0 })
This way the element still occupies space like you want, it just has a 0
opacity, so it's effectively the same as it being visibility: hidden
when it finishes.
Yes, there's an alternative. It's called .fadeTo()
, where you set the target opacity, which in your case will be 0
.
$('element').fadeTo( 1000, 0 ); // fade to "0" with a 1000ms duration
This will not alter the display
property at the end.