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;

No comments:

Post a Comment