<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <!--bootstrap要引入的文件:bootstrap.min.css,jquery.min.js,bootrap.min.js--> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> <script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script> <!--要在bootstrap之前引入jquery,bootstrap依赖JQUERY,因为bootstrapJS里要使用$这个jquery变量--> <!--<script src="js/popper.js" type="text/javascript" charset="utf-8"></script>--> <!--如果你要用bootstrap使用一些提示性的交互,那么就需要引入提示性的框架popper.js,因为bootstrap的提示就是依赖popper--> <script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div class="container"> <div class="row"> <div class="alert alert-danger col-6 offset-3"> 这是1个弹框<a class="alert-link" href="http://www.baidu.com">百度</a> <button type="button" class="close" data-dismiss="alert"> <span>×</span> </button> </div> </div> </div> <div class="alert alert-primary" role="alert"> This is a primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-secondary" role="alert"> This is a secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-success" role="alert"> This is a success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-danger" role="alert"> This is a danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-warning" role="alert"> This is a warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-info" role="alert"> This is a info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-light" role="alert"> This is a light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <div class="alert alert-dark" role="alert"> This is a dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like. </div> <script type="text/javascript"> $('.alert').on('close.bs.alert',function(e){ console.log('弹框关闭之前执行什么内容') console.log(e) }).on('closed.bs.alert',function(e){ console.log('弹框关闭之后执行什么内容') console.log(e) }) </script> </body> </html>