我使用Bootstrap導航欄的菜單,我已經添加下拉菜單,子菜單下,我想打開懸停子菜單,因爲它是點擊,我用一些方法,但沒有它正常工作,我的代碼如下:下拉菜單懸停在Bootstrap導航欄
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Branding Image -->
<div class="logo-container">
<a class="navbar-brand" href="{{ url('/home') }}">
{{-- {{ config('app.name', 'Laravel') }} --}}
<img src="{{URL::asset('/')}}Images/group_65.jpg" class="img-responsive logo-images imgcenter">
</a>
</div>
</div>
<div class="collapse navbar-collapse" id="app-navbar-collapse" style="margin-left: 150px">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav main-menu">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">My Classes<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Change Class</a></li>
<li><a href="#">Groups</a></li>
</ul>
</li>
<li><a href="">Roster</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Admin<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="" href="#">Manage Users</a>
<ul class="dropdown-menu">
<li><a href="#">All Users</a></li>
<li><a href="#">Admin</a></li>
</ul>
</li>
<li><a href="#">Programs</a></li>
<li><a href="#">Documents</a></li>
<li class="dropdown-submenu">
<a class="" href="#">Gallery</a>
<ul class="dropdown-menu">
<li><a href="#">Calendar</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Holidays</a></li>
</ul>
</li>
<li><a href="#">Staff Attendance</a></li>
<li><a href="#">Payroll</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Food</a></li>
</ul>
<li><a href="">SoCo Help</a></li>
</li>
</ul>
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ route('login') }}">Login</a></li>
<li><a href="{{ route('register') }}">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{-- {{ Auth::user()->username }} <span class="caret"></span> --}}
<img class="avtar" src="uploads/profile/{{Auth::user()->user_profile_pic}}" style="height: 19px;">
{{ Auth::user()->first_name}} {{Auth::user()->last_name }}<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{-- <i class="fa fa-fw fa-sign-out"> Logout</i> --}}
<i class="glyphicon glyphicon-log-out"></i> Logout
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
@endif
</ul>
</div>
</div>
我添加腳本下拉子菜單爲
$('.dropdown-submenu a').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
那麼什麼是實現這一目標的正確方法?它也應該爲崩潰而工作。
https://stackoverflow.com/questions/8878033/how-to-make-twitter-bootstrap-menu-dropdown-on-hover-rather-than-click – tech2017
[如何讓嘰嘰喳喳的可能的複製引導菜單下拉懸停而不是點擊](https://stackoverflow.com/questions/8878033/how-to-make-twitter-bootstrap-menu-dropdown-on-hover-rather-than-click) –