我在其他问题中没有找到我想要的答案,所以我来问一下。
这是我使用jQuery UI创建手风琴的代码。
$('.blog-m-post').accordion({
header: "h3",
active: "true"
});
我的问题是文档状态
内容面板必须是其相关标题的紧随兄弟节点。
但是,使用我的标记,内容面板不是紧随标题,而是在其后一个位置。
示例:
<div class="blog-m-post">
<h3>My blog post title</h3>
<div class="foo"> <!-- this becomes the collapsed element -->
<p>Posted on: 8th Aug</p> <p>Author: John Doe</p>
</div>
<div class="content"> <!-- but I want THIS to collapse instead -->
<p>my content inside here</p>
</div>
</div>
我该如何让
.content
成为可折叠的元素,因为当前是 .foo
?在排序方面,
.foo
需要保持原样以便默认显示。 .content
是内部内容应该展开和折叠的位置。