我想克隆一个 div 并将其附加到使用 jQuery 的 HTML 表中的另一个元素。例如
我想复制 divsection_title
并将其立即附加到append_class
跨度中。换句话说,div section_title
FIRST TITLE将被附加到 span 中append_class
,同样如此。
这是HTML
<tr class="tr_class">
<th scope="row">
<div class="section_title">FIRST TITLE</div>
</th>
<td>
RANDOM CONTENT...
</td>
</tr>
<span class="append_class"></span>
<tr class="tr_class">
<th scope="row">
<div class="section_title">SECOND TITLE</div>
</th>
<td>
RANDOM CONTENT...
</td>
</tr>
<span class="append_class"></span>
<tr class="tr_class">
<th scope="row">
<div class="section_title">THIRD TITLE</div>
</th>
<td>
RANDOM CONTENT...
</td>
</tr>
<span class="append_class"></span>
我的尝试失败了。
var cloneTitle= $('.tr_class').find('.section_title').clone();
$('.append_class').html(cloneTitle);
它确实克隆但它会克隆所有section_title
并相应地附加它们。
对此的任何指导将不胜感激。
提前致谢