通过getElementsByClassName方式获取dom会得到HTMLCollection类型的列表,他是类数组对象,不支持foreach方法。
可以通过:
Array.prototype.map.call(document.getElementsByTagName('li),function())
实现遍历
通过getElementsByClassName方式获取dom会得到HTMLCollection类型的列表,他是类数组对象,不支持foreach方法。
可以通过:
Array.prototype.map.call(document.getElementsByTagName('li),function())
实现遍历