如何用加号和减号图标显示div?有保证金的div不起作用?如何隐藏/显示div文本?

时间:2013-10-04 08:40:48

标签: javascript jquery html css

我正在尝试源代码,请检查演示链接:

http://jsfiddle.net/bala2024/nvR2S/40/

$('.expand').click(function(){
    $(this).stop().animate({
        width:'73%',
        height:'130px'
    });
    $('.collapse').show();
});

1 个答案:

答案 0 :(得分:1)

您只需要在css样式中隐藏所有段落元素:

.expand p {
    display: none;
}

然后在jquery代码的帮助下显示\隐藏所需的项目。

$('.expand').click(function(){
    $(this).stop().animate({
        width:'73%',
        height:'130px'
    });
    $(this).find('p').show();
    $('.collapse').show();
});

 $('.collapse').on('click',function(e){
     e.stopPropagation()
     $(this).parent('.expand').stop().animate({
         width: '30px',
         height:'130px'
     });
     $(this).prev('p').hide();
     $(this).hide();
 });

我也创建了一个演示fiddle,所以请检查一下。