Jquery menu with sub menu hover

天大地大妈咪最大 提交于 2019-12-12 09:14:54

问题


I have a menu and sub-menu system which is self explanatory, you hover over something in the main menu options and then you are presented with a sub menu of options.

There is a problem if you hover to see the main menu options, but then mouse away without selecting from the sub menu, the sub-menu doesn't slide up.

You can see it working here (I know the css is bloated but I have just copied the entire sheet in:

http://jsfiddle.net/6sres/

This is the Jquery I am using:

$('#nav li').hover(

     function () {
          //show its submenu
          $('ul', this).stop().slideDown(100);
     }, 

     function () {
          //hide its submenu
      $('ul', this).stop().slideUp(10);
     }

);

$('a#leagueSelect').hover(function(){

     $('ul.fixture-list').slideDown(50);        

});

I know it is something simple, perhaps related to the "this" which is causing some issues.

Thanks,

Alan.


回答1:


You didn't make any function that handles the event when a#leagueSelect is not hovered anymore.

jsFiddle Demo

$('a#leagueSelect').hover(function(){
     $('ul.fixture-list').slideDown(50);        
},
function(){
     $('ul.fixture-list').slideUp(50);          
});


来源:https://stackoverflow.com/questions/18636908/jquery-menu-with-sub-menu-hover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!