How do you pause before fading an element out using jQuery?

后端 未结 8 492
滥情空心
滥情空心 2020-12-29 03:12

I would like to flash a success message on my page.

I am using the jQuery fadeOut method to fade and then remove the element. I can increase the duratio

相关标签:
8条回答
  • 2020-12-29 04:14
    var $msg = $('#msg-container-id');
    $msg.fadeIn(function(){
      setTimeout(function(){
        $msg.fadeOut(function(){
          $msg.remove();
        });
      },5000);
    });
    
    0 讨论(0)
  • 2020-12-29 04:15

    For a pure jQuery approach, you can do

    $("#element").animate({opacity: 1.0}, 5000).fadeOut();
    

    It's a hack, but it does the job

    0 讨论(0)
提交回复
热议问题