Toggle not working on hover in a menu

515 views Asked by At

I have been fighting a lot with this for many hours and seems strange when I see the same working on Fiddle but the same thing doesn't work in my code. Here, I paste my HTML and JS, CSS can be seen here: http://jsfiddle.net/rd6bX/76/

<div class="center-menu">       
        <ul>
                <li class="bbw-user-link glyphicon glyphicon-chevron-left" ><a href="" style="color:white;">item to be hovered</a>

                    <div class="menu middle">
                    <ul>
                            <li><a href="#">Some Menu Item</a></li>
                            <li><a href="#">Another Item</a></li>
                            <li><a href="#">Another Item</a></li>

                    </ul>                       
                    </div>                  

                </li>

        </ul>

JQuery code:

jQuery('.center-menu ul li').hover(function () {
    jQuery(this).children('.menu.middle').toggle();
}); 
1

There are 1 answers

2
thecodeparadox On BEST ANSWER

Try this:

jQuery(function (){
  jQuery('.center-menu ul li').hover(function () {
    jQuery(this).children('.menu.middle').toggle();
  }); 
});