I\'m trying to set get id of all elements in an HTMLCollectionOf. I wrote the following code:
var list = document.getElementsByClassName(\"event
you can add this two lines:
HTMLCollection.prototype.forEach = Array.prototype.forEach;
NodeList.prototype.forEach = Array.prototype.forEach;
HTMLCollection is return by getElementsByClassName and getElementsByTagName
NodeList is return by querySelectorAll
Like this you can do a forEach:
var selections = document.getElementsByClassName('myClass');
/* alternative :
var selections = document.querySelectorAll('.myClass');
*/
selections.forEach(function(element, i){
//do your stuffs
});