展开/折叠问题 [英] Expand/Collapse Issue
本文介绍了展开/折叠问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一次只展开/折叠一个容器.当我单击第一个容器时,第二个容器应折叠,而当第二个容器展开时,第一个容器应自动折叠.以下是小提琴.请指导...谢谢
I want to expand/collapse only one container at a time. When I click on first container second container should collapse and when second container expanded, first container should collapse automatically. Following is the Fiddle. Please guide... Thanks
http://jsfiddle.net/awaises/eK8X5/1138/
jQuery
$(".header").click(function () {
$header = $(this);
$content = $header.next();
$content.slideToggle(500, function () {
$header.text(function () {
return $content.is(":visible") ? "Collapse" : "Expand";
});
});
});
推荐答案
您可以将此行添加到点击处理程序中:
You can add this line to your click handler:
$(".header").not(this).text('Expand').next().slideUp();
Updated Fiddle
这篇关于展开/折叠问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文