[英]Bootstrap modal does not show
I have the following bootstrap modal: 我有以下引导程序模式:
<div class="popupCover">
<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" onClick="closeModal()" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> </button>
</div>
<div class="modal-body">
<h4>Text1</h4>
<p>Text2</p>
</div>
</div>
</div>
</div>
</div>
I am trying to open it with 我正在尝试用
<script type="text/javascript">$('#myModal').modal('show')</script>
However, this does not work. 但是,这不起作用。 Can anyone see the error? 谁能看到错误? Thanks! 谢谢!
You should add jQuery and bootstrap.js files, and bootstrap script should be added after jQuery 您应该添加jQuery和bootstrap.js文件,并且应该在jQuery之后添加bootstrap脚本。
You can see the working pen here 你可以在这里看到工作笔
HTML: HTML:
<div class="popupCover">
<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" onClick="closeModal()" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> </button>
</div>
<div class="modal-body">
<h4>Text1</h4>
<p>Text2</p>
</div>
</div>
</div>
</div>
</div>
JS: JS:
$('#myModal').modal('show');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.