Can Twitter Bootstrap alerts fade in as well as out?

前端 未结 10 501
夕颜
夕颜 2020-12-07 09:28

When I first saw the alerts in Bootstrap I thought they would behave like the modal window does, dropping down or fading in, and then fading out when closed. But it seems li

10条回答
  •  余生分开走
    2020-12-07 10:10

    This is very important question and I was struggling to get it done (show/hide) message by replacing current and add new message.

    Below is working example:

    function showAndDismissAlert(type, message) {
    
      var htmlAlert = '
    ' + message + '
    '; $(".alert-messages").prepend(htmlAlert); $(".alert-messages .alert").hide().fadeIn(600).delay(2000).fadeOut(1000, function() { $(this).remove(); }); }
    
    
    
    

    Hope it will help others!

提交回复
热议问题