I'm aware of appendChild and createElement but these are methods to use when I'm adding a single line of HTML. I recognize I could add a script object, or an iframe object using this approach, but how would I in JavaScript add 20+ lines of HTML to an existing HTML document?
I built a search.js file to address searching requirements of an HTML page. It works great! But I want to encapsulate my search form and CSS and was thinking I could append the data to an existing HTML document to keep things compact and more manageable.
UPDATE: So the JavaScript would be added to an existing HTML page at the bottom within two SCRIPT tags. The JS would append a string - which would be 20+ lines of HTML stringified - to an existing page, which I had hoped would render as HTML.
var sectionAsHtml = '' +
'<div class='xyz'>' +
' <div class='abc'>' +
' <p>This is just an example for demonstration purposes.</p>' +
' </div>' +
'</div>';
I would then locate the body of my HTML using a ".getElementById" find, and then ".appendChild" the above string.