你好,我现有的物品清单。我想在列表的内部添加一个DIV,以使用引导扩展/折叠功能。
我想在10个项目之后添加div,并链接到列表中的最后一个位置。
谢谢!
<div id="list">
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<!-- there is place for new DIV (after 3 items) -->
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<!-- there is place for end DIV -->
<!-- there is place for LINK (last position) -->
<a href="" class="collapse show">Show</a>
<!-- there is place end LINK -->
</div>
这样的事情?
$('#list').append('<div class="item">some content</div>');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="list">
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<!-- there is place for new DIV (after 3 items) -->
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<div class="item">some content</div>
<!-- there is place for end DIV -->
<!-- there is place for LINK (last position) -->
<a href="" class="collapse show">Show</a>
<!-- there is place end LINK -->
</div>
<div class="container">
<h2>Araba</h2>
<div class="inner">Merhaba</div>
<div class="inner">Gule gule</div>
</div>
此代码也可用于添加所需的位置
$( "<p>Deneme</p>" ).append( ".inner" );