Ano*_*ous 2 jquery twitter-bootstrap laravel
我让 Bootstrap 模式窗口弹出存储的会话数据,但我无法关闭它。我不得不将类“show”添加到 div 中,以便它甚至出现。
@if (Session::has('message'))
<script type="text/javascript">
$(window).load(function() {
$('#confirm').modal('show');
});
</script>
<div class="modal show" id="confirm">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span>×</span><span class="sr-only">Close</span></button>
<h4>{{ Session::get('message') }}</h4>
</div>
<div class="modal-body">
<p>You are now signed up for our newsletter.</p>
</div>
</div>
</div>
</div>
@endif
Run Code Online (Sandbox Code Playgroud)
您的模式应该可以通过调用正常显示$('#confirm').modal('show'),因此请检查您的浏览器控制台是否有任何 javascript 错误。至于关闭它也很简单:
$('#confirm').modal('hide');
Run Code Online (Sandbox Code Playgroud)
这是一个在加载时自动打开并在等待 5 秒后关闭它的示例:http : //jsfiddle.net/7wt719p3/1/
确保在 Bootstrap JS 插件文件之前加载 jQuery。Bootstrap 需要 jQuery 才能使其插件(如模态)工作。以下是使用 CDN 包含它的方法:
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
Run Code Online (Sandbox Code Playgroud)