admin管理员组文章数量:1313733
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/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src=".10.9/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src=".10.9/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href=".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">×</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>
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./jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables/1.10.9/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables/1.10.9/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn./bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables/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">×</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>
Share
Improve this question
edited Nov 19, 2015 at 12:14
Roope Hakulinen
7,4056 gold badges45 silver badges66 bronze badges
asked Nov 19, 2015 at 12:03
Ritz ArlekarRitz Arlekar
3851 gold badge4 silver badges20 bronze badges
3 Answers
Reset to default 2you have to include bootstrap.min.js after the jQuery.js
<!-- Latest piled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
You have two problems:
- You are missing a library,
bootstrap.js
- 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./jquery-1.11.3.min.js"></script>
<!-- this file was missing -->
<script type="text/javascript" src="//maxcdn.bootstrapcdn./bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables/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/1.10.9/js/dataTables.bootstrap.min.js"></script>
You are not including the bootstrap.js in your code.
本文标签: javascriptBootstrap modal popup not workingStack Overflow
版权声明:本文标题:javascript - Bootstrap modal popup not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741959023a2407160.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论