javascript - Using Bootstrap Nav option I need to exclude the end item from Hover -
my menu created bootstrap nav menu script. works fine except need not include last item want use button click event. code below shows how menu set out in index.html file.
<body> <div class="row"> <nav class="navbar"> <div class="col-md-offset-2 col-md-8"> <div class="logo col-md-1"> <img src="images/logo.png" /> </div> <div> <ul class="nav navbar-nav navbar-right menu"> <li class="dropdown"> <a href="#" class="dropdown-toggle">home<span style="color:#ff6633; padding:5px;" class="glyphicon glyphicon-menu-down" /></a> <ul style="background-color:#383838" class="dropdown-menu"> <li><a href="#" style="color:#d8d8d8">community</a></li> <li><a href="#" style="color:#d8d8d8">our blog</a></li> <li><a href="#" style="color:#d8d8d8">maps blog</a></li> <li><a href="#" style="color:#d8d8d8">eng blog</a></li> <li><a href="#" style="color:#d8d8d8">advertisers</a></li> <li><a href="#" style="color:#d8d8d8">publishers</a></li> <li><a href="#" style="color:#d8d8d8">about us</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle">event<span style="color:#ff6633; padding:5px;" class="glyphicon glyphicon-menu-down" /></a> . . . . </li> <li class="search-bttn"> <a href="#"><span class="glyphicon glyphicon-search"></span></a> <ul style="background-color:#383838" class="searchbox"> <li><input type="text" class="searchbox" id="search_text" placeholder="search" /></li> </ul> </li> </ul> </div> </div> </nav> </div>
i have tried several different ways place condition in script file use hover 'li' if dropdown class nothing works. below scipt.js file
var main = function () { $('.menu > li').hover( function () { $(this).find('ul').fadein(10); }, function () { $(this).find('ul').fadeout(10); } ); }; $(document).ready(main);
i can't exclude html nav 'ul' how can tell script class in use can use condition exclude it?
you can use :not in jquery:
var main = function() { $('.menu > li:not(.search-bttn)').hover( function() { $(this).find('ul').fadein(10); }, function() { $(this).find('ul').fadeout(10); } ); }; $(document).ready(main);
Comments
Post a Comment