最佳答案
我试图使用 forEach 遍历从 getElementsByTagName("input")
返回的所有元素。有什么想法为什么这不工作在 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>