作为引导程序模式激活内容
如果你想把内容设置为引导模式,那么就要用 .modal(options) 方法。
点击按钮后,模态框会像下面的脚本中那样生成。
$(document).ready(function(){ $("#button1").click(function(){ $("#newModal1").modal({backdrop: true}); }); });
上面的 “backdrop:ture”设置已经完成。我们还可以设置另一个选项,即 “backdrop: true” −
backdrop: true = 单击模式框外部,关闭它。 backdrop: false = 单击模式框外部,不会关闭它。 |
可以尝试运行以下代码以实现模态框(“选项”)类别 −
例
<!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Sample</h2> <button type="button" class="btn btn-default btn-lg" id="button1">Modal One</button> <button type="button" class="btn btn-default btn-lg" id="button2">Modal Two</button> <div class="modal fade" id="newModal1" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Sample Modal 1</h4> </div> <div class="modal-body"> <p>Click outside to close it.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> </div> </div> </div> </div> <div class="modal fade" id="newModal2" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Sample Modal 2</h4> </div> <div class="modal-body"> <p>It won't close on clicking outside.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> <script> $(document).ready(function(){ $("#button1").click(function(){ $("#newModal1").modal({backdrop: true}); }); $("#button2").click(function(){ $("#newModal2").modal({backdrop: false}); }); }); </script> </body> </html>
广告