Javascript Ajax jQuery Html PHP Example Quiz New MORE

Show hide Bootstrap Modal Using jQuery


<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h3>Show hide Modal Example Using jQuery</h3>
  <!-- Button to Open the Modal -->
  <button type="button" class="btn btn-success" id="show">
    Open modal
  </button>
 

  <!-- The Modal -->
  <div class="modal" id="myModal">
    <div class="modal-dialog">
      <div class="modal-content">
     
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Modal Heading</h4>
          <button type="button" class="close" data-dismiss="modal">×</button>
        </div>
       
        <!-- Modal body -->
        <div class="modal-body">
          Modal body..
        </div>
       
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" id="hide">Close</button>
        </div>
       
      </div>
    </div>
  </div>
 
</div>
<script>
$("#show").click(function(){
  $('#myModal').modal('show');
 });
$("#hide").click(function(){
 $('#myModal').modal('hide');
});
</script>
</body>
</html>

Run it yourself