View on GitHub

Dismissible alert

Using the alert JavaScript plugin CSS code, it’s possible to dismiss any alert inline. Here’s how:

You can see this in action with a live demo:

<input class="noojs-button" type="checkbox" id="alert1close">
<div class="alert alert-warning alert-dismissible fade" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <label for="alert1close" class="btn-close" aria-label="Close"></label>
</div>

Show the alert after button click

In javascript, the alert is shown by calling $(...).show(); We are only using CSS, so that is not possible. Instead, hide the alert by setting the input[checked] and add a label to show the alert.

<label for="alert1openclose" class="btn btn-primary" aria-label="Open alert"></label>
<input class="noojs-button" type="checkbox" id="alert1openclose">
<div class="alert alert-warning alert-dismissible fade" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <label for="alert1openclose" class="btn-close" aria-label="Close"></label>
</div>