Here's my demo.
I'm trying to get the JavaScript forEach
method to work in Google Chrome.
Caniuse hasn't been much help. :(
Any help would be appreciated! Thanks!
Convert the NodeList to an array:
nodes = Array.prototype.slice.call(nodes);
Then you can use .forEach()
on it.
document.querySelectorAll
doesn't return array but a NodeList
object which has no method 'forEach'.
The error msg shows you that:
Object #<NodeList> has no method 'forEach'
Check this article, which explains this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With