jQuery Bootstrap Alerts

A jQuery plugin for displaying Bootstrap alerts

View on GitHub Download .zip Download .tar.gz

Basic usage

jQuery('#alert-container').bootstrapAlert({
  message: 'This is a info message.',
});

Examples

Code

<script>
  // Default usage
  $('#default-alert').click(function () {
    $('#alert-container').bootstrapAlert({
      message: 'This is a <b>default</b> message.'
    });
  });

  // Success
  $('#success-alert').click(function () {
    $('#alert-container').bootstrapAlert({
      type: 'success',
      message: 'This is a <b>success</b> message.'
    });
  });

  // Info
  $('#info-alert').click(function () {
    $('#alert-container').bootstrapAlert({
      type: 'info',
      message: 'This is a <b>info</b> message.'
    });
  });

  // Warning
  $('#warning-alert').click(function () {
    $('#alert-container').bootstrapAlert({
      type: 'warning',
      message: 'This is a <b>warning</b> message.'
    });
  });

  // Danger
  $('#danger-alert').click(function () {
    $('#alert-container').bootstrapAlert({
      type: 'danger',
      message: 'This is a <b>danger</b> message.'
    });
  });

  // With Heading
  $('#alert-heading').click(function () {
    $('#alert-container').bootstrapAlert({
      heading: 'My heading',
      message: 'This is a <b>info</b> message with heading.'
    });
  });

  // Without clear
  $('#alert-no-clear').click(function () {
    $('#alert-container').bootstrapAlert({
      clear: false,
      message: 'This is a <b>info</b> message without clear container.'
    });
  });

  // With glyphicons
  $('#alert-glyphicons').click(function () {
    var glyphicon = '<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>';
    $('#alert-container').bootstrapAlert({
      message: glyphicon + ' This is a message with glyphicons, Font Awesome can be used also.'
    });
  });
</script>

Options

Property Type Description Default Values
type string Type of alert 'info' 'success', 'info', 'warning' or 'danger'
dismissible bool Shows the dismiss button in the alert box. true
heading string Shows the heading alert box. empty
message string Required. Message of the alert empty
clear bool Clears the container before shows the alert true