1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <!DOCTYPE html> <html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> 下拉菜单的事件 </title> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="../bootstrap/css/bootstrap-theme.min.css"> <script type="text/javascript" src="../jquery-3.1.1.js"></script> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> </head>
<body> <div class="container"> <div class="dropdown"> <a class="btn btn-default dropdown-toggle" type="button" aria-haspopup="true" aria-expanded="true" data-toggle="dropdown" id="dropMenu"> 下拉菜单(带分隔条) <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#">新建</a></li> <li><a href="#">打开</a></li> <li><a href="#">保存</a></li> <li role="separator" class="divider"></li> <li><a href="#">退出</a></li> </ul> </div> </div> <script type="text/javascript"> $(".dropdown").on("show.bs.dropdown", function (e) { console.log("下拉菜单开始显示"); }).on("shown.bs.dropdown", function (e) { console.log("下拉菜单显示完成"); }).on("hide.bs.dropdown", function (e) { console.log("下拉菜单开始隐藏"); }).on("hidden.bs.dropdown", function (e) { console.log("下拉菜单隐藏完成"); }) </script> </body>
</html>
|