bootstrap alert message auto close code example

Example 1: bootstrap warning message with close button

<div class="alert alert-success alert-dismissible">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Success!</strong> Indicates a successful or positive action.
</div>

Example 2: bootstrap alert auto close

$("#success-alert").fadeTo(2000, 500).slideUp(500, function(){
    $("#success-alert").slideUp(500);
});

Example 3: bootstrap alert auto close

$(document).ready(function() {
  $("#success-alert").hide();
  $("#myWish").click(function showAlert() {
    $("#success-alert").fadeTo(2000, 500).slideUp(500, function() {
      $("#success-alert").slideUp(500);
    });
  });
});

Example 4: bootstrap alert box

Alerts in Bootstrap:
--------------------------------
Alert classes you can use to check
.alert-primary
.alert-secondary
.alert-success
.alert-danger
.alert-warning
.alert-info
.alert-light
.alert-dark

Simple alert:
-------------
<div class="alert alert-primary" role="alert">
  This is a primary alert—check it out!
</div>

Alert with close button and decriptive feature:
------------------------------------------------
<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

Trigger via javascript:
$(".alert").alert();

Example 5: bootstrap Alerts Additional content Dismissing

<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

Enable dismissal of an alert via JavaScript:

$('.alert').alert()
$().alert('close')
$().alert()
$().alert('dispose')

Events

close.bs.alert
closed.bs.alert