2014-09-12 96 views
0

病人:http://demo.imatte.us/fomru/project_people.html隱藏菜單(jQuery的,CSS)

屏幕:http://i.stack.imgur.com/GkBST.png

隱藏菜單作品不正確。點擊鏈接後,菜單顯示,但'鼠標懸停'後消失。我需要禁用此功能,並在點擊菜單後隱藏菜單。

(function($) { 
    $(function(){ 
     var $judgments = $('.project .jugdments-list .item'); 
     $judgments.each(function(){ 
      limit($(this).find('.title'), 140); 
      limit($(this).find('.text'), 200); 
     }); 

     var $filters = $('.filters-list>li'); 
     $filters.each(function(){ 
      var $filter = $(this); 
      var $filterBody = $filter.find('.filter'); 
      $filter.find('.filter-name').click(function(){ 
       $('.filters-list .filter').not($filterBody).fadeOut(); 
       $filterBody.fadeToggle(); 
      }); 
     }); 
     $(document).click(function(e){ 
      if (!$(e.target).closest('.filters-list').length || $(e.target).is('.filters-list')) { 
       $('.filters-list .filter').fadeOut(); 
      } 
     }); 
    }); 

    function limit($elem, length) { 
     var text = $elem.text(); 
     if (text.length > length) { 
      $elem.text(text.slice(0, 140)+'…'); 
     } 
    } 
})(jQuery); 
+0

你想他們是顯示在懸停? – heroin 2014-09-12 10:31:19

回答

2

如果我得到正確的你是什麼意思,那麼這個應該可以幫助您:

刪除

.filters .filters-list>li:hover .filter { 
    display: block; 
} 

,這增加:

$('.filter-name').each(function() { 
    var that = $(this); 
    that.hover(
     function() { 
      $('.filters-list .filter').not(that.parent().find('.filter')).fadeOut(); 
      that.parent().find('.filter').fadeIn(); 
     }, 
     function() {} 
    ) 
}); 
+1

謝謝!這就是我需要的。 – posthack 2014-09-12 12:13:45