Showing posts with label How to use innerhtml in JavaScript?. Show all posts
Showing posts with label How to use innerhtml in JavaScript?. Show all posts

Wednesday, April 27, 2016

How to use innerhtml in JavaScript?

var maincontent = document.getElementById("content").innerHTML;
maincontent = "<p>" + first;
On the second line you're overwriting the variable, not setting the .innerHTML. This is what you want:
var maincontent = document.getElementById("content");
maincontent.innerHTML = "<p>" + first;