Reputation: 402
I first run this to get my cloned data
var cloned = $(".hoverer:first").clone().attr({id: 'id_'+itm_id, class: 'hoverer-active'});
That div has a div within it that has an id and class, and that div also has a div in it that has id and class, and I am trying to access the data of the 3rd 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>
Upvotes: 1
Views: 2020
Reputation: 16061
Here is a jsFiddle with an example : http://jsfiddle.net/DavidLaberge/bjNMj/
Upvotes: 0
Reputation: 86892
This is the selector for that div within your cloned object. Rembember in jquery when selecting an element you can provide a second parameter that defines the context in which to search.
$("#bus2", clone);
Upvotes: 1
Reputation: 196217
You can use the cloned
variable as the context of new jquery commands..
So you can do
$('#bus2', cloned).attr('id', newid); // to alter the id if you know the existing one
alternatively, since the cloned
variable holds a jquery object you can use the .find
method to find content inside it..
cloned.find('#bus2').attr('id',newid);
Upvotes: 8