關於“靜態模態框沒有顯示出來”的解決辦法
阿新 • • 發佈:2019-01-01
以下是Bootstrap文件中給出的“靜態模態框”的例項
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true"> ×</span><span class="sr-only">Close</span>
</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</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><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div ><!-- /.modal -->
但是,執行之後,靜態模態框並載入不出來,調查之後發現,需要加上以下程式碼:
<script>
$(document).ready(function(){
$('#myModal').modal('show');
})
</script>
這樣就可以正常顯示啦~~~