Is there a trick to inject arbitrary content into the DOM, and then select on that content, without knowing what the content is?
Example:
function myInjector( _htmlElement ) {
$('#target').replaceWith(_htmlElement);
/* Is it possible to then select the injected element here? */
}
I appreciate any advice provided.
Thanks.
You don’t need to select it – you already have a reference to it stored in the
_htmlElementvariable:Edit — just create the new jQuery object first and store it in a variable: