fade out div after x seconds with jquery

前端 未结 3 598
旧巷少年郎
旧巷少年郎 2021-02-05 05:28

I do a fade in div that is not displayed when I load the page:

    $(\'#overlay\').fadeIn(\'fast\');
    $(\'#box\').fadeIn(\'slow\');

I would

3条回答
  •  -上瘾入骨i
    2021-02-05 05:52

    You could use setTimeout()

    var xSeconds = 1000; // 1 second
    
    setTimeout(function() {
       $('#overlay').fadeOut('fast');
       $('#box').hide();
    }, xSeconds);
    

提交回复
热议问题