2011-09-22 145 views
-1

下面的代碼隱藏.titlerow懸停.row。如何更改代碼,以便鼠標不在任何行上徘徊,然後隱藏第一個.titlerow幫助懸停jquery

echo "<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div>"; 

$(function() { 

    $('.row').hover(function() { 

    $(this).find('.titlerow').hide(); 
    }, function() { 
     $(this).find('.titlerow').show(); 
    }); 
}); 

回答

1

我希望這是你的意思,如果不是請詳細說明你的內涵是什麼?

HTML:

<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div> 
<div class='row'><div class='titlerow'></div></div> 

腳本:

$(function() { 
    $('.row').hover(function() { 
     $('.titlerow').first().show(); 
     $(this).find('.titlerow').hide(); 

    }, function() { 
     $(this).find('.titlerow').show(); 
     $('.titlerow').first().hide(); 
    }); 

    // hide the first titlerow 
    $('.titlerow').first().hide(); 
}); 

編輯

在上面的代碼中,我爲您的新請求做了一些修復。 +工作的例子可以在下面

工作示例中找到: http://jsfiddle.net/muqxj/

+0

感謝它的工作原理開始,但是當我將鼠標懸停在一排,然後把所有在一起的第一titlerow所示。 – user892134

+0

那麼請詳細解釋一下你希望發生的事情,因爲我不太明白預期的行爲是什麼......如果你徘徊,你希望它隱藏你想讓它顯示的假,但是第一次一個需要隱藏? – Sander

+0

我想要第一個.titlerow被隱藏起來,這是正確的。 .row的懸停,.titlerow隱藏,這是正確的。現在,如果所有的.row都沒有被徘徊,那麼第一個.titlerow應該被再次隱藏,但事實並非如此。 – user892134