+ 3

How do i use "document.body.innerHTML" without removing the rest of the page?

I have a code like an rpg, and I want to write a variable onto the page with document.body.innerHTML but without removing the rest of the page.

4th Mar 2018, 2:59 AM
Punderful20 Quack
Punderful20 Quack - avatar
3 odpowiedzi
+ 6
If you only want to change a particular part of the body content you may better wrap the content to be changed within a div having an Id, and you then change the div's content instead (using getElementById function), this way other parts of the document's body are not in risk for unintentional change, just an idea : )
4th Mar 2018, 4:52 AM
Ipang
+ 6
you can do what @Ipang said to make a different content by wrapping the content to be changed or @Don't Mess With Texas said to append a new content after the last content in the part
4th Mar 2018, 5:34 AM
Amethyst Animion
Amethyst Animion - avatar
+ 3
Unfortunately I cannot test it now but I think += should work.
4th Mar 2018, 3:13 AM
Kevin Eldurson
Kevin Eldurson - avatar