Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  133] [ 6]  / answers: 1 / hits: 24685  / 9 Years ago, thu, november 19, 2015, 12:00:00

I have a simple HTML file in which I want to display Bootstrap modal popup. Below is the code for this.



.js file:



 <meta name=viewport content=width=device-width, initial-scale=1>
<link rel=stylesheet href=/po_ritesh/css/bootstrap.min.css>

<script type=text/javascript src=//code.jquery.com/jquery-1.11.3.min.js></script>
<script type=text/javascript src=https://cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js></script>
<script type=text/javascript src=https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js></script>


<link rel=stylesheet type=text/css href=//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css>
<link rel=stylesheet type=text/css href=https://cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css>

<link rel=stylesheet type=text/css href=./css/home.css>
<script src=./js/global.js></script>
<script src=./js/home.js></script>


button control:



 <button class=myBtn type=button data-toggle=modal data-target=#myModal>test </button>


modal div:



<div class=modal fade id=myModal tabindex=-1 role=dialog aria-labelledby=myModalLabel>
<div class=modal-dialog role=document>
<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>
test
</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>

More From » jquery

 Answers
186

You have two problems:




  1. You are missing a library, bootstrap.js

  2. Your JavaScript files are referenced in the wrong order, causing a JavaScript error. This error prevents your browser from running additional script and the modal code doesn't work.



Try this:



<script type=text/javascript src=//code.jquery.com/jquery-1.11.3.min.js></script>

<!-- this file was missing -->
<script type=text/javascript src=//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js></script>

<script type=text/javascript src=https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js></script>

<!-- this file was moved after the jQuery Datatables library was laoded -->
<script type=text/javascript src=https://cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js></script>

[#64341] Tuesday, November 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
juand

Total Points: 366
Total Questions: 95
Total Answers: 90

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;