Bootstrap 3 Modal not working

3.2k views Asked by At

I have searched and used other code examples but none of them launch a modal for me. I copied this modal code straight from the bootstrap website (version 3) and added the header. I feel like im missing something really dumb so please dont be too harsh :) Thanks!

     <head>
  <link rel="stylesheet" href="css/bootstrap.css">
  <script src="js/jquery.js" type="text/javascript"></script> 
  <script src="js/bootstrap.js" type="text/javascript"></script>
</head>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
1

There are 1 answers

0
Leonardy Kristianto On

Firstly, have you checked that you have no broken links to the appropriate files (jquery.js/ bootstrap.css/ bootstrap.js) on each respective folders? You can try using cdn instead to check whether bootstrap.js is really working in your local machine

<!-- CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.css" rel="stylesheet" type="text/css">

<!-- JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js" type="text/javascript">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.js" type="text/javascript">