How to add content to html body using JS?

后端 未结 8 2062
孤城傲影
孤城傲影 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:09

    I Just came across to a similar to this question solution with included some performance statistics.

    It seems that example below is faster:

    document.getElementById('container').insertAdjacentHTML('beforeend', '
    content html
    ');

    InnerHTML vs jQuery 1 vs appendChild vs innerAdjecentHTML.

    Reference: 1) Performance stats 2) API - insertAdjacentHTML

    I hope this will help.

提交回复
热议问题