Append HTML file contents to div - Javascript

23 Views Asked by At

Is it possible to appendChild(index.html) ?

I know it's possible to do this:

fetch(`${htmlFile}`)
  .then((res) => {
    if (res.ok) {
      return res.text();
    }
  })
  .then((htmlSnippet) => {
    targetElement.innerHTML = htmlSnippet;
  });

But for some reason, the changed HTML of targetElement doesn't react to any of my other javascript functions.

0

There are 0 best solutions below