How to add content to html body using JS?

后端 未结 8 2039
孤城傲影
孤城傲影 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 07:50

    You can use

    document.getElementById("parentID").appendChild(/*..your content created using DOM methods..*/)
    

    or

    document.getElementById("parentID").innerHTML+= "new content"
    

提交回复
热议问题