我试图在页面加载时启动Bootstrap模式而不触发HTML按钮或使用jQuery.
这是我的代码:
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<div id="my-modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Title</h4>
</div>
<div class="modal-body">
Hello World!
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这在你打电话时有效
$('#my-modal').modal('show');
Run Code Online (Sandbox Code Playgroud)
但我不想调用方法或触发按钮.有没有办法在页面加载时自动启动模态?