using getElementById and innerHTML to change the html of content no jquery

this is pretty simple, but i always forget it so ill add it here

document.getElementById("theid").innerHTML = "the new content";

heres how it works, add a div with an id of theid



<div id="theid">..</div>

you can expand this out a bit if you like and assign the get element to a variable like this

var theid = document.getElementById("theid");

then we tell it to replace the innerHTML of it

theid.innerHTML = "the new content";

the content you see above should say "the new content" rather than the three dots as when the page was loaded

you can also add html in there, just have to watch the ' and " are escaped properly with \

Other Items in js
Page Views

This page has been viewed 200 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
All of humanity's problems stem from man's inability to sit quietly in a room alone, wrote Blaise Pascal.