HTMLCollection is NOT an array !
The HTMLCollection interface represents a generic collection (array-like object) of elements (in document order).
So... If u want to use the method of Array like slice(), u need to convert HTMLCollection in advance.
Solution
var convertedArray = Array.prototype.slice.call(YourHtmlCollection)
var convertedArray = [].slice.call(YourHtmlCollection);
var convertedArray = slice.call(YourHtmlCollection);
沒有留言:
張貼留言