【发布时间】:2014-05-14 17:54:50
【问题描述】:
我不知道为什么我会被困在这个问题上,但我就是!尝试克隆div,然后在jQuery 中使用children 修改其内容。我在这里遗漏了一些东西,因为它没有像我预期的那样工作。见小提琴:http://jsfiddle.net/v7A2T/
Javascript (jQuery):
$test = $('#clone-container').clone().appendTo('#append');
$test.children('h2').text('my clone'); // works
$test.children('.remove-row').remove(); // doesn't work
还有 HTML:
<div id="clone-container" class="hidden">
<h2>Location name</h2>
<div class="table-responsive">
<table class="table">
<thead>
<th>one</th><th>two</th><th>three</th>
<th>four</th><th>five</th><th>six</th>
</thead>
<tbody>
<tr class="remove-row"><td colspan="6">Remove this text from clone</td></tr>
</tbody>
</table>
</div> <!-- .table-responsive -->
</div>
<div id="append"></div>
【问题讨论】:
-
findvschildren,旧的 jQuery 初始陷阱。
标签: javascript jquery clone children