Convert NodeList to array

后端 未结 4 1598
不知归路
不知归路 2021-01-12 03:25

I\'m having a hard time converting a NodeList to an array in IE 8. The following works perfectly in Chrome, but in IE 8 toArray() is not recognize

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 03:53

    First, don't use document.all -- it's non-standard and deprecated. Use document.getElementsByTagName to get the DIV elements in your case.

    Second, don't extend DOM objects such as NodeList -- built-in objects are a very strange breed and are not required to behave like any other objects that you generally work with. See this article for an in-depth explanation of this: What's wrong with extending the DOM.

提交回复
热议问题