Best way to create large static DOM elements in JavaScript?

前端 未结 5 1577
野性不改
野性不改 2020-12-23 10:13

I have many elements that one of my JS widgets needs to create and add to the DOM often. They never change.

So one option would be to store the HTML itself as a stri

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-23 10:28

    If you are looking for performance I would stick with the first version because in the second one everytime you are calling $('

    ') or $('') you are creating a new jQuery Object and then call .append() which also another method call you do.
    I would go with the first one.

    提交回复
    热议问题