What is the most efficient way to create HTML elements using jQuery?

后端 未结 12 2500
甜味超标
甜味超标 2020-11-22 06:40

Recently I\'ve been doing a lot of modal window pop-ups and what not, for which I used jQuery. The method that I used to create the new elements on the page has overwhelming

12条回答
  •  鱼传尺愫
    2020-11-22 07:05

    I use $(document.createElement('div')); Benchmarking shows this technique is the fastest. I speculate this is because jQuery doesn't have to identify it as an element and create the element itself.

    You should really run benchmarks with different Javascript engines and weigh your audience with the results. Make a decision from there.

提交回复
热议问题