I'm currently rebuilding a user 'subscribe' form used to be loaded synchronously and document.write was used to append everything to the page, but I have to load jQuery async first so I had to stick to DOM manipulation.
What I'm trying to do is append the main element of this form where everything else is nested.
So in my form I create all of nodes using document.createElement and then append them with container.appendChild(content)
<div class="main">
<!-- form contents -->
</div>
Now, I can append everything inside the form to .main but how do I append this form in a specific place in the document itself?
For example
<body>
<div class='container'>
<script src='form_script.js'>
<!-- div.main to be generated in div.container -->
</script>
</div>
</body>
How can I select the element that like in function .closest() is the DOM node that the script was pasted into?