For loop for HTMLCollection elements

前端 未结 12 1302
挽巷
挽巷 2020-11-22 04:20

I\'m trying to set get id of all elements in an HTMLCollectionOf. I wrote the following code:

var list = document.getElementsByClassName(\"event         


        
12条回答
  •  清歌不尽
    2020-11-22 04:42

    On Edge

    if(!NodeList.prototype.forEach) {
      NodeList.prototype.forEach = function(fn, scope) {
        for(var i = 0, len = this.length; i < len; ++i) {
          fn.call(scope, this[i], i, this);
        }
      }
    }
    

提交回复
热议问题