2012-07-23 56 views
0

正如你所看到的我是新的jQuery中,我想要做一個簡單的效果,在哪裏你過濾與菜單鏈接的畫廊,我希望不透明度改變懸停,並點擊我需要懸停停止工作。 我試過的是在點擊時添加一個「.disabled」類,它添加到我的菜單鏈接中, 並將懸停功能設置爲.not(."disabled"),但顯然懸停在dom準備好後未檢查課程,我該如何解決這個問題?關於如何優化此功能的任何其他指針都會有所幫助。 在此先感謝。 Clazzid無法獲得.not()類選擇器工作在這個

這裏是我的代碼:

$('#menu-item-43 a ,#menu-item-44 a, #menu-item-42 a, #menu-item-64 a').click(function() { 
       $('#menu-item-43 a ,#menu-item-44 a, #menu-item-42 a, #menu-item-64 a').addClass('disabled'); 
      }); 


      $('#menu-item-42 a').click(function() { 
       $('.exhibition, .prototyping').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-42 a').click(function() { 
       $('.design').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-43 a').click(function() { 
       $('.design, .prototyping').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-43 a').click(function() { 
       $('.exhibition').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-44 a').click(function() { 
       $('.design, .exhibition').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-44 a').click(function() { 
       $('.prototyping').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-64 a').click(function() { 
       $('.design, .exhibition, .prototyping').stop().animate({ opacity: 1.0 }, 500); 
      }); 



      $('#menu-item-42 a').not('.disabled').hover(function() { 
       $('.exhibition, .prototyping').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-42 a').not('.disabled').hover(function() { 
       $('.design').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-43 a').not('.disabled').hover(function() { 
       $('.design, .prototyping').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-43 a').not('.disabled').hover(function() { 
       $('.exhibition').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-44 a').not('.disabled').hover(function() { 
       $('.design, .exhibition').stop().animate({ opacity: 0.0 }, 500); 
      }); 
      $('#menu-item-44 a').not('.disabled').hover(function() { 
       $('.prototyping').stop().animate({ opacity: 1.0 }, 500); 
      }); 

      $('#menu-item-64 a').not('.disabled').hover(function() { 
       $('.design, .exhibition, .prototyping').stop().animate({ opacity: 1.0 }, 500); 
      }); 

回答

0

我認爲你應該做這樣的

$('#menu-item-43 a').hover(function() { 
    if (!$(this).hasClass('disabled')) 
     $('.exhibition').stop().animate({ opacity: 1.0 }, 500); 
}); 
+0

感謝鄭氏!工作只是我需要它,學習越來越多:) – Clazzid 2012-07-23 02:10:53

+0

不客氣! – 2012-07-23 02:24:50