Why can't I delay a remove call with jQuery

前端 未结 3 1900
野的像风
野的像风 2021-02-07 03:12

I would like for a div to fadeOut and then be removed:

 $(\'#div\').delay(1000).fadeOut(300);
 $(\'#div\').delay(1300).remove();

Unfortunately,

3条回答
  •  你的背包
    2021-02-07 04:00

    If you want the element to be removed after it's done being faded out, you can fadeOut's callback parameter.

    $('#div').delay(1000).fadeOut(300, function(){
       $(this).remove();
    });
    

提交回复
热议问题