.modal is not a function

Posted by w3diy - 4 months ago

Uncaught TypeError: $(...).modal is not a function

Bootstrap : TypeError: $(…).modal is not a function

also check if jQuery is not included twice

$('document').ready(function() {
  $('#Product').click(function() {
    $('#users').modal('show');
  });
});

CSS part

body {
  background-color: #3d3d3d;
  padding-top: 42px;
  padding-bottom: 42px;
}

HTML Part

<html>
<head>
  <meta charset="utf8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Bootstrap : TypeError: $(…).modal is not a function</title>
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <title>Modal - www.infinityknow.com</title>
</head>

<body>
  <div class="dsp container">
    <button id="Product" class="btn btn-primary dsp">Display Product Details</button>
    <div id="users" role="dialog" class="modal fade">
      <div class="dsp modal-dialog">
        <div class="dsp modal-content">
          <div class="dsp modal-header">
            <button type="button" data-dismiss="modal" class="close">&times;</button>
            <h4 class="dsp modal-title">Error</h4>
          </div>
          <div class="dsp modal-body">
            <p>Bootstrap : TypeError: $(…).modal is not a function</p>
          </div>
          <div class="dsp modal-footer">
            <button type="button" data-dismiss="modal" class="dsp btn btn-primary">Close</button>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>

</html>