Dynamically creating Bootstrap CSS alert messages

This answer refers to Bootstrap 2.

When an alert is closed, it is removed from the DOM.

If you want to an alert to reappear later, make sure to not put data-dismiss="alert" in the close button as follows:

<div class="alert fade in" id="login-error" style="display:none;">
    <button type="button" class="close">×</button>
    Your error message goes here...
</div>

Then, bind the close button to simply hide the alert when it’s pressed:

$('.alert .close').on('click', function(e) {
    $(this).parent().hide();
});

When you want the tooltip to reappear, simply show it.

$('#login-error').show();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)