Possible Duplicate:
How can I get a reference to a node directly after it is appended?
as an example:
$(document).append('<div class="new-elem" />');
how do i now store the above newly created element into a variable so i can use it like this:
newElem.append('div class="another-new-element" />');
where newElem is the element i appended to the document initially?
i’m assuming it can’t be done like:
var newElem = $(document).append('<div class="new-elem" />');
You can do the opposite with
appendTo: