Javascript 在jQuery中查找克隆元素的子元素

Javascript 在jQuery中查找克隆元素的子元素,javascript,jquery,clone,children,Javascript,Jquery,Clone,Children,我不知道为什么我被困在这上面,但我是!尝试克隆div,然后使用jQuery中的子项修改其内容。我在这里遗漏了一些东西,因为它没有像我预期的那样工作。参见小提琴: Javascript(jQuery): 以及HTML: <div id="clone-container" class="hidden"> <h2>Location name</h2> <div class="table-responsive"> <t

我不知道为什么我被困在这上面,但我是!尝试克隆
div
,然后使用jQuery中的
子项修改其内容。我在这里遗漏了一些东西,因为它没有像我预期的那样工作。参见小提琴:

Javascript(jQuery):

以及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>

地点名称
一二三
fourfivesix
从克隆中删除此文本

。删除行
不是克隆元素的直接子元素。替换此项:

$test.children('.remove-row').remove();
为此:

$test.find('.remove-row').remove();

假设我克隆了一个TR,我想在TR的TD中搜索一个按钮,然后我可以这样做。按钮的类别为“绿色”


find
vs
children
,旧jQuery的初始值。
$test.find('.remove-row').remove();
var tr = $(this).closest("tr").clone();
tr.children().find('button.green').hide(); // or show