Which is better: string html generation or jquery DOM element creation?

后端 未结 4 590
逝去的感伤
逝去的感伤 2020-12-05 08:12

Ok, I\'m rewriting some vanilla JS functions in my current project, and I\'m at a point where there\'s a lot of HTML being generated for tooltips etc.

My question is

4条回答
  •  粉色の甜心
    2020-12-05 08:46

    Favour DOM manipulation over innerHTML methods. For one thing, DOM manipulation will correctly handle characters that need to be escaped with innerHTML. For another, it is typically faster, sometimes much faster.

提交回复
热议问题