Working with some legacy architecture and because of the nature of the initialization sequence I need to wrap an element before it's been added to the document. Say I have the following:
<div id="containerX">
<div id="myNode"></div>
</div>
And I need to wrap "myNode" before it's added to the DOM. Do jQuery selectors even work in this context? If so, how can I make that happen? I've tried passing in the element like so:
(Corrected some typos here referred to in some answers below):
$(this.element).wrap('<div id="'+ "myWrapper_" + this.id + '"></div>');
with no luck. I'm assuming that the usual syntax for selectors won't work since the nodes are outside the document. The closest thing I've found was this post here: Manipulate DOM elements before adding them to the document but the difference between my situation and his is I don't have strings, I have elements created with document.createElement that have not been appended.
Can anyone point me in the right direction or is this even possible?
Thanks