bootstrap modal on show jquery code example

Example 1: programmatically show modal boostrap

$('#myModal').modal('show');

Example 2: modal boostrap

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modalId">
  ---
</button>

<div class="modal fade" id="modalId">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">title</h5>
		<button type="button" class="close" data-dismiss="modal" aria-label="Close">
        	<span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        
      </div>
      <div class="modal-footer">
  		<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Example 3: how to show bootstrap modal

<script>
    var myModal = new bootstrap.Modal(document.getElementById('ModalID'))
    myModal.show()
</script>

Example 4: show a modal

<a onclick=\"$('#login').modal('hide');$('#lost').modal('show');\" href='#'>Click</a>

Tags: