jQuery fadeOut without display none?

后端 未结 6 901
死守一世寂寞
死守一世寂寞 2020-12-08 03:54

Is there an alternative to fadeOut() that doesn\'t use display:none for the style? I\'d like to just use visibility hidden to avoid any sort of shifting in the page layout?

6条回答
  •  遥遥无期
    2020-12-08 04:06

    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.

提交回复
热议问题