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

前端 未结 5 1765

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:01

    I have another suggestion. You can select multiple nodes by query seperator(,):

    var nodes = document.querySelectorAll('h2, h3');
    

    This code selects all h2 and h3 saved in nodes.

提交回复
热议问题