Concat two nodelists

前端 未结 4 1210
夕颜
夕颜 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:40

    Why don't you use one selector to select them at the same time than you do not need to concat them and you end up with an HTML Collection instead of an Array.

    var elems = document.querySelectorAll("ul > li, .mobile > *");
    console.log(elems);
    • x
    y

提交回复
热议问题