-4

So imagine I received this string back from my server:

'<h1>hello everyone</h1>'

How can I turn this string into actual HTML that I can insert into my document?

tilly
  • 2,229
  • 9
  • 34
  • 64

1 Answers1

0

Try it:

var response = '<h1>hello everyone</h1>';
document.getElementById('localContainer').innerHTML = response;
// or
document.write(response);
<div id="localContainer"></div>
  • Thanks for the response, but that doesn't work with HTML strings. I tried the link to the other post and tried it with div.insertAdjacentHTML and that worked – tilly Jun 13 '18 at 12:34