DEV Community

sundaycrunk
sundaycrunk

Posted on

Answer: How to render HTML in string with Javascript?

You can render HTML using document.write()

document.write('<html><body><h2>HTML</h2></body></html>')

But to append existing HTML string, you need to get the id of the node/tag under which you want to insert your HTML string.

There are two ways by which you can possibly achieve this:

  1. Using DOM -
var tag_id = document.getElementById('tagid');
var

Top comments (0)