I’m familiar with the preferred method of creating elements with jQuery:
jQuery('<div/>', {
id: 'foo',
href: 'http://google.com',
}).appendTo('#mySelector');
But I need to create some elements with that are a little more complex than what the above does. Is there a way I can build my code so that it outputs something like:
<div id="foo" href="http://google.com">
<h1> Heading </h1>
<div id="child-div">
Conetent created from jQuery vars
</div>
</div>
You can simple pass the html string to the jQuery function
or create each element individually