Skip to content
Advertisement

fade out animation for session flash message

Is there any way to set up a flash message session for laravel? Which means when I click the button to add or delete item(s), the flash messages are displayed. But Is there any way to fade out?

in view file I put the code below:-

  <script>
      $(document).ready(function(){
          setTimeout(function() {
              $('#msg').fadeOut('fast');
          }, 30000);
      });
  </script>

  @if (session('status'))
      <div class="alert alert-success">
          <p class="msg"> {{ session('status') }}</p>
      </div>
  @endif

Controller file which I used for return the message.

return back()->with('status', $pro->pro_name . ' add to cart successfully');

Advertisement

Answer

Try this

<script>
      $(document).ready(function(){
    $('.alert-success').fadeIn().delay(10000).fadeOut();
      });
  </script>

  @if (session('status'))
      <div class="alert alert-success">
          <p class="msg"> {{ session('status') }}</p>
      </div>
  @endif
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement