2012-04-04 98 views

回答

0

只需添加

$(".newsBody").hide(); 
$('.newsTeaser').show(); 

$(".more").click(function() {

DEMO第一線:http://jsfiddle.net/nJpNb/5/

但請緩存中的項目。

+0

優秀,作品治療.. – webworker 2012-04-04 20:48:30

+0

隨時接受答案。 – binarious 2012-04-04 20:49:53

0

嘗試增加下面兩行的.more點擊如下圖所示內,

//hide all others and show newsTeaser 
$newsItem.find('.newsBody').hide(); 
$newsItem.find('.newsTeaser').show(); 

DEMO

完整代碼:

$(".newsBody").hide(); 
var $newsItem = $('.newsItem'); 
$(".more").click(function() { 

    //hide all others and show newsTeaser 
    $newsItem.find('.newsBody').hide(); 
    $newsItem.find('.newsTeaser').show(); 

    var $parent = $(this).parent(); 
    $parent.hide(); 
    $parent.parent().find(".newsBody").show(); 
}); 
$(".less").click(function() { 
    var $parent = $(this).parent(); 
    $parent.hide(); 
    $parent.parent().find(".newsTeaser").show(); 

}); 
+0

謝謝,這個解決方案也可以。 – webworker 2012-04-04 20:49:18

0

設置ID給每個部分(讓他們有一個類和id)。然後當有人選擇第2部分,然後自動隱藏第1部分和第3部分