Chapter 7: innerHTML

265 7 1
                                    

The innerHTML method-thing sets the value or inner HMTL (if you will) to whatever you set it to. The thing about this is that it edits the actual HTML so you will not use parameters but you will use a string.
To use innerHTML, you will have to create an object. You can use a variable, but there is another more advanced way...

document.getElementById('varName').innerHTML = "This is inside anything with the id varName";
Or you can just create a variable
var newVar = document.getElementById('varName');
newVar.innerHTML = "This is another way to use innerHTML";
This way is a little bit more line consuming, but looks neater.

Overall it's basically just
object.innerHTML = "";

JavaScript for NewbiesWhere stories live. Discover now