Concat two nodelists

前端 未结 4 1199
夕颜
夕颜 2021-02-04 02:17

I am trying to concat two nodelists using

var ul   = document.querySelector(\"ul\");
var down = document.getElementsByClassName(\"mobile\")[0];
var ul_child = Ar         


        
4条回答
  •  北海茫月
    2021-02-04 02:41

    Set() ensures items are unique and the ES6 Spread operator makes it neat & tidy:

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

提交回复
热议问题