Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<div class="navbar navbar-inverse no-border bg0">
                <div class="container-fluid">
            <!---Brand and toggle get grouped for better mobile display--->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>

                        </button>
                        <!--<div class="navbar-brand">
                            <a href="index.html"><img src="" class="img img-responsive" style=""><span>COMPANY LOGO</span></a>
                        </div>-->
                    </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="menu">
                            <ul class="nav navbar-nav navbar-right">
                                <li menu-level="1"] class="active"><a href="index.html"><span data-hover="Home">Home</span></a></li>
                                <li menu-level="1"><a href="about.html"><span data-hover="help">About Us </span></a></li>
                                <li menu-level="1" class="dropdown drop1"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span data-hover="login">Training Programmes ^__i class="fa fa-angle-down"></span></a>
                                  <ul class="dropdown-menu drop11">
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2" class="dropdown drop2"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Website Designing <span class="caret"></span></a>
                                          <ul class="dropdown-menu drop22">
                                              <li menu-level="3"><a href="#">Website Designing</a></li>
                                              <li menu-level="3"><a href="#">Website Designing</a></li>
                                              <li menu-level="3"><a href="#">Website Designing</a></li>
                                              <li menu-level="3" class="dropdown drop3"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Website Designing</a>
                                                  <ul class="dropdown-menu drop33">
                                                      <li menu-level="4"><a href="#">Website Designing</a></li>
                                                      <li menu-level="4"><a href="#">Website Designing</a></li>
                                                      <li menu-level="4"><a href="#">Website Designing</a></li>
                                                   </ul>
                                              </li>
                                              <li menu-level="3"><a href="#">Website Designing</a></li>
                                          </ul>
                                      </li>
                                      <li><a href="#">Commerce Classes</a></li>
                                    </ul menu-level="2">
                                </li>
                                <li menu-level="1" class="dropdown drop1"><a href="contact.html" class="dropdown-toggle" data-toggle="dropdown"><span data-hover="login">Contact Us</span></a>
                                    <ul class="dropdown-menu drop11">
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                      <li menu-level="2"><a href="#">Website Designing</a></li>
                                    </ul>
                                </li>
                                <li menu-level="1"><a href="contact.html"><span data-hover="login">Testimonials</span></a></li>
                            </ul>

                    </div>
                </div>
            </div>
</div>


What I have tried:

JavaScript
$(".drop1").mouseenter(function(){
             $(".drop11").slideDown();
			 }).mouseleave(function(){
             $(".drop11").slideUp();
			 });
			 
			 $(".drop2").mouseenter(function(){
             $(".drop22").slideDown();
			 }).mouseleave(function(){
             $(".drop22").slideUp();
			 });
			 
			 $(".drop3").mouseenter(function(){
             $(".drop33").slideDown();
			 }).mouseleave(function(){
             $(".drop33").slideUp();
			 });
Posted
Updated 12-Dec-18 3:00am

You need to find the specific sub-menu within the current menu, rather than animating everything with the sub-menu class.
JavaScript
$(".drop1").mouseenter(function(){ 
    $(this).find(".drop11").slideDown(); 
}).mouseleave(function(){ 
    $(this).find(".drop11").slideUp(); 
});
 
Share this answer
 
From your javascript/jQuery for the drop1 part
JavaScript
//all css class with drop1
$(".drop1")
	.mouseenter(function(){
		//all css class with drop11 do the slideDown
		$(".drop11").slideDown();
	})
	.mouseleave(function(){
		//all css class with drop11 do the slideUp
		$(".drop11").slideUp();
	})
;
and looking at the markup
The css class drop1 and drop11 are being used for both "Training Programmes" and "Contact Us"

On the browser when the mouseenter/mouseleave are occurring for drop1, all drop11 will do slideDown/slideUp respectively.

Do something like this to find the associated child dropdown-menu for the mouseenter/mouseleave events.
JavaScript
//slidedown dropdown children dropdown-menu when enter and slideup when leave
$(".dropdown")
	.mouseenter(function() {
		$(this).find('> .dropdown-menu').slideDown();
	})
	.mouseleave(function() {
		$(this).find('> .dropdown-menu').slideUp();
  	})
;

Here is a jsfiddle with your markup added and javascript as above example:
JSFiddle[^]

Hopefully it should point you in the correct direction.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900