官方地址:https://github.com/CWSpear/bootstrap-hover-dropdown
1,下载及链接插件
jQuery,bootstrap,bootstrap-hover-dropdown三个插件。<本测试基于bootstrap3.0.2>
<!-- script order matters! --> <script src="/path/to/jquery.min.js"></script> <script src="/path/to/bootstrap.min.js"></script> <script src="/path/to/bootstrap-hover-dropdown.min.js"></script>
2,使用
1)自动启动
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="false"> Account <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a tabindex="-1" href="#">My Account</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Change Email</a></li> <li><a tabindex="-1" href="#">Change Password</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Logout</a></li> </ul> </li>
2)通过js启动
$('.dropdown-toggle').dropdownHover(options);
Options
- delay: 毫秒级延迟. This is the time to wait before closing a dropdown when the mouse is no longer over the dropdown or the button/nav item that activated it. Defaults to
500
. - instantlyCloseOthers: (optional) A boolean value that when true, will instantly close all other dropdowns matched by the selector used when you activate a new navigation. This is nice for when you have dropdowns close together that may overlap. Default is
true
.