我有一组动态构建的 div,可以包含几行内容。我们将输出限制为每行三列。使用 jquery toggle 切换 div 中的某些内容,我试图移动下面的每个 div(以垂直方式)以留出读取切换元素的空间。我已经尝试使用以下标记:
<script type="text/javascript">
$(".trigger").click(function () {
var trigger = $(this);
$(this).next(".toggle").slideToggle();
});
</script>
<div id="toggleContainer">
<div>
<h3 class="trigger">Trigger 1</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 2</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 3</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 4</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 5</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 6</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 7</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 8</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
<div>
<h3 class="trigger">Trigger 9</h3>
<ul class="toggle">
<li>Line One</li>
<li>Line Two</li>
<li>Line Three</li>
</ul>
</div>
</div>
此外,在这个小提琴中展示
这会将下面的每个元素向右移动,以允许查看切换的内容。我的问题是:如何在不将行向右移动的情况下将内容向下移动到下一行?这是我要完成的示例:
A1 A2 A3
B1 B2 B3
C1 C2 C3
单击 A1 时,B1 和 C1 的状态将是:
A1 A2 A3
A1 切换 B2 B3
B1 C2 C3
C1