foreach.js低版本IE数组和HTMLCollection元素集合不兼容forEach循环遍历的处理方法

时间:2022-12-30 19:15:33
【文件属性】:
文件名称:foreach.js低版本IE数组和HTMLCollection元素集合不兼容forEach循环遍历的处理方法
文件大小:1KB
文件格式:JS
更新时间:2022-12-30 19:15:33
foreach 低版本IE数组和HTMLCollection元素集合不兼容forEach循环遍历的处理方法 原生JavaScript通过name获取dom元素得到的是 HTMLCollection元素集合 要想循环遍历可以用forEach,但是在低于ie9的版本下不兼容 var list= document.getElementsByName("name"); for (var i = 0; i < list.length; i++) { console.log(list[i].id); //second console output }

网友评论