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

后端 未结 12 2492
甜味超标
甜味超标 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 06:52

    Actually, if you're doing $('

    '), jQuery will also use document.createElement().

    (Just take a look at line 117).

    There is some function-call overhead, but unless performance is critical (you're creating hundreds [thousands] of elements), there isn't much reason to revert to plain DOM.

    Just creating elements for a new webpage is probably a case in which you'll best stick to the jQuery way of doing things.

提交回复
热议问题