2011-12-22 15 views
0

我想要使用jQuery添加懸停不透明度正在重複的元素取決於數據庫中有多少項目。jQuery懸停單個元素是重複的

在盤旋一格以上時,他們都在變化。

下面是HTML/jQuery的: 了的jsfiddle不顯示任何結果,但希望它是顯示你的代碼的最佳方式http://jsfiddle.net/RKhvv/1/

道歉。

謝謝!

+0

盪滌你的小提琴,但HTML doesn't包含與類'entryHeader'任何元素。 http://jsfiddle.net/WTyGw/ – Stefan 2011-12-22 09:52:07

回答

0

試試這個:

$(document).ready(function() {   
     $(".entryHeader").hover(function(){ 
      $(this).stop(true).fadeTo("fast", 0.6); // This sets the opacity to 100%  on hover 
     },function(){ 
      $(this).stop(true).fadeTo("fast", 1.0); // This sets the opacity back to 60% on mouseout 
     }); }); 
+0

謝謝,這工作完美! – Gareth 2011-12-22 09:53:29

0

您需要抓取當前正在懸停的元素,而不是全部使用相同的類。

我將圍繞你已經抓住用相同的類,然後設置每一項單獨

1

更改JavaScript以下面的元素循環。 $(this)使stop調用僅適用於要懸停的元素,而不適用於entryHeader類的所有元素。

$(document).ready(function() {   
    $(".entryHeader").hover(function(){ 
    $(this).stop(true).fadeTo("fast", 0.6); // This sets the opacity to 100% on hover 
    },function(){ 
     $(this).stop(true).fadeTo("fast", 1.0); // This sets the opacity back to 60% on mouseout 
    }); 
}); 

jsFiddle與新的代碼。