2012-04-04 59 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部分