我試圖循環遍歷所有使用forEach從getElementsByTagName("input")
重構的元素。任何想法爲什麼這不適用於FF,Chrome或IE?JavaScript:循環遍歷從getElementsByTagName返回的所有元素
<html>
<head>
</head>
<body>
<input type="text" value="" />
<input type="text" value="" />
<script>
function ShowResults(value, index, ar) {
alert(index);
}
var input = document.getElementsByTagName("input");
alert(input.length);
input.forEach(ShowResults);
</script>
</body>
</html>
理由爲什麼沒有'forEach':http://stackoverflow.com/questions/13433799/why-doesnt-nodelist-have-foreach –