How to add content to html body using JS?

后端 未结 8 2044
孤城傲影
孤城傲影 2020-11-28 07:19

I have many

in my html and want to add more through javascript. However, using innerHTML is just replacin
8条回答
  •  孤城傲影
    2020-11-28 08:05

    I think if you want to add content directly to the body, the best way is:

    document.body.innerHTML = document.body.innerHTML + "bla bla";
    

    To replace it, use:

    document.body.innerHTML = "bla bla";
    

提交回复
热议问题