Pop up with Bootstrap when loading page

4

How can I make a Bootstrap pop up when loading the page?

<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      ...
    </div>
  </div>
</div>
    
asked by anonymous 03.09.2014 / 17:06

1 answer

10

First apply an ID to the modal:

<div id="myModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      ...
    </div>
  </div>
</div>

Then in tags <script></script> put:

$(document).ready(function() {
   $('#myModal').modal('show');
});
    
03.09.2014 / 18:38