Is it possible to append an element to a JavaScript nodeList?

前端 未结 5 1747

I\'m generating content dynamically, so I\'m often ending up with documentFragments which I\'m querying using querySelectorAll or querySelector

5条回答
  •  有刺的猬
    2021-02-13 06:18

    Use ES6 Set():

    var elems = new Set([
        ...document.querySelectorAll(query1),
        ...document.querySelectorAll(query2)
    ]);
    

提交回复
热议问题