Here's what I'm doing:
window.onload = () => {
const position = document.getElementsByClassName('className')[0];
const html = 'MULTIPLE LINES OF HTML';
position.insertAdjacentHTML('afterbegin', html);
};
Currently I've concatenated multiple lines of HTML, which is kinda messy and difficult to work with.
I'd prefer to work with the HTML in an HTML file and just use "const html = index.html" if possible (or something that will help avoid concatenating HTML inside of a variable).
I've tried "const html = index.html" and was expecting it to just use the HTML in the file (this is my first personal project, I'm new to JavaScript, and have no idea what the correct way to do this is, if any).
When I tried this I get an "Uncaught ReferenceError: html is not defined"
*I also tried referencing this question: Assigning an html file to a variable
...and couldn't figure it out still. (I'm new to this so node.js is foreign to me.)
I've been searching for hours and haven't found a solution...
Any help is much appreciated!