我首先运行它来获取我的克隆数据
var cloned = $(".hoverer:first").clone().attr({id: 'id_'+itm_id, class: 'hoverer-active'});
该 div 中有一个包含 id 和 class 的 div,该 div 中也有一个包含 id 和 class 的 div,而我正在尝试访问第三个 div 的数据?
<div id="id_2" class="hoverer-active">
<div id="sub1" class="test">
<div id="bus2" class="tset">
data i want to play with
</div>
</div>
</div>
最佳答案
您可以使用cloned
变量作为context新的 jquery 命令..
所以你可以这样做
$('#bus2', cloned).attr('id', newid); // to alter the id if you know the existing one
或者,由于 cloned
变量包含一个 jquery 对象,因此您可以使用 .find
查找其中内容的方法..
cloned.find('#bus2').attr('id',newid);
关于jquery - 在 jQuery 中,如何访问克隆的 div 对象中的子 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7490259/