2012-06-13 55 views
1

我有一個包含重疊圖像的列表。當我將鼠標懸停在圖像上時,文本和覆蓋圖會假設使用JQuery消失。當我將鼠標懸停在圖像上時,該特定圖像的覆蓋圖消失,這是正確的。問題是文字。當我將鼠標懸停在圖像上時,該圖像和所有其他圖像上的文字消失。我只想要隱藏該特定圖像的文本和疊加層。這似乎是一個小問題,因爲我得到的覆蓋工作正確。在此先感謝朋友。JQuery腳本的小問題

這裏是JQuery的:

//Hides the screen and text on mouseover 
$('.screen').mouseover(function() { 
    $('.screen_text').hide(); 
    $(this).slideUp(400); 

}); 
//Shows the screen and text on mouseout 
$('.portfolio img').mouseout(function() { 
    $('.screen_text').show(); 
    $('.screen').slideDown(400); 

}); 
+0

一些標記會很好。 – Radu

回答

3

沒有看到你的HTML實體模型,我的假設是,你的jQuery選擇帶回所有的文本元素 我想你想要做的是一樣的東西:

$('.screen_text',this).hide(); 

應該只帶回了在這個

+0

謝謝。這最終爲我工作。 – Sephiroth

+0

很高興我能幫上忙 – Nir

2

類選擇是匹配太多。

//Hides the screen and text on mouseover 
$('.screen').mouseover(function() { 
    $(this).find('.screen_text').hide(); 
    $(this).slideUp(400); 

}); 
//Shows the screen and text on mouseout 
$('.portfolio img').mouseout(function() { 
    $('.screen_text').show(); 
    $('.screen').slideDown(400); 

}); 

使用jQuery的.find()搜索.screen_text.screen的後裔這是上徘徊。 (「 screen_text」,因爲你正在做$())

2

問題上下文中的類名screen_text的元素是,你正躲在每個具有類名「screen_text」當您執行$('.screen_text').hide();元素。你應該找到一個更好的方式來選擇或區分它們。

沒有辦法提供任何更多的支持沒有看到一個DOM的例子。雖然這個jQuery的執行過程中可能存在邏輯錯誤,但在語法上沒有任何錯誤。