Why does document.querySelectorAll return a StaticNodeList rather than a real Array?

前端 未结 6 816
北恋
北恋 2020-11-30 01:11

It bugs me that I can\'t just do document.querySelectorAll(...).map(...) even in Firefox 3.6, and I still can\'t find an answer, so I thought I\'d cross-post on

6条回答
  •  孤独总比滥情好
    2020-11-30 01:31

    I think you can simply do following

    Array.prototype.map.call(document.querySelectorAll(...), function(...){...});
    

    It works perfect for me

提交回复
热议问题