The .fadeOut() method to use visibility property instead of display property

前端 未结 3 782
抹茶落季
抹茶落季 2020-12-03 11:16

The .fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none, so the element no longer affects

3条回答
  •  遥遥无期
    2020-12-03 11:30

    Use jQuery's fadeTo() and then have a callback set the visibility. Example:

    $('#fade').on("click", function(){
        $(this).fadeTo(500, 0, function(){
            $(this).css("visibility", "hidden")
        }) // duration, opacity, callback
    })
    
    Click to Fade
    
    This won't move

提交回复
热议问题