Re:Vanilla JS, fast, lightweight, cross-platform framework
by masklinn on Monday August 27, 2012 @03:49AM
(#4437856)
Except #forEach is a method of Array, and getElementsByTagName does not return an Array but a NodeList. Which doesn't have any of Array's methods (it has a length, it can be indexed, and it has an alternative indexation method - #item — but it's not an array at all)
[ Parent
| on HN ]
Re:Vanilla JS, fast, lightweight, cross-platform framework
by nailer on Monday August 27, 2012 @07:24PM
(#4441379)
You're right. I wasn't sure earlier, as I was typing on a phone with no JS console.
but never mind:
Array.forEach.call(paragraphs, function(paragraph){paragraph.innerHTML = 'Hello.';})
will work fine.