我的脚本运行正常:
$('.trigger').not('.trigger_active').next('.toggle_container').hide();
$('.trigger').click( function() {
var trig = $(this);
if ( trig.hasClass('trigger_active') ) {
trig.next('.toggle_container').slideToggle('slow');
trig.removeClass('trigger_active');
} else {
$('.trigger_active').next('.toggle_container').slideToggle('slow');
$('.trigger_active').removeClass('trigger_active');
trig.next('.toggle_container').slideToggle('slow');
trig.addClass('trigger_active');
};
return false;
});
我的html结构如下所示:
<div class="group">
<div class="item1">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item2">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item3">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item4">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
</div>
<div class="group">
<div class="item5">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item6">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item7">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
<div class="item8">
<div class="trigger"></div>
<div class="trigger_container"></div>
</div>
</div>
但是当手风琴打开时,我希望div“group”获得一个填充底部,其高度为div“trigger_content”的高度。当手风琴关闭时,corse表示“div”填充底部为“0”。
你可以帮帮我吗? THX答案 0 :(得分:0)
尝试类似的事情:
$('.group').css('padding-bottom', $('trigger_content').height())