小编在学习BS V3 结果下拉事件始终无法触发 结果原文的一句 话提醒了我:All dropdown events are fired at the .dropdown-menu
's parent element.
好吧parent element不是兄弟元素 是父元素 。
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Bootstrap 实例 - 下拉菜单(Dropdown)插件方法 v3.3.5测试</title>
- <link href="./css/bootstrap.min.css" rel="stylesheet">
- <script src="./js/jquery.min.js"></script>
- <script src="./js/bootstrap.min.js"></script>
- <script>
- $(function(){
- $('#dropdownparent').on('show.bs.dropdown', function () {
- alert("beforeshow");
- });
- $('#dropdownparent').on('hidden.bs.dropdown', function () {
- alert("closed");
- });
- });
- </script>
- </head>
- <body>
- <div class="dropdown" id="dropdownparent">
- <button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
- Dropdown trigger
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu" aria-labelledby="dLabel">
- <li>1</li>
- <li>1</li>
- </ul>
- </div>
- </body>
- </html>
时间:2015-08-26 09:20
来源:Linuxeden
作者:zhangkai
原文链接