我正在尝试遍历从getElementsByTagName("input")使用 forEach返回的所有元素。任何想法为什么这在 FF、Chrome 或 IE 中不起作用?
<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>