HTML:
<body>
<canvas id="canvas1"></canvas>
<canvas id="canvas2"></canvas>
</body>
Javascript:
window.onload = function() {
var canvasElements = document.getElementsByTagName("canvas");
for ( var index in canvasElements) {
}
for ( var index = 0; index < canvasElements.length; index++) {
}
}
这两个循环没有相同的迭代次数。你知道为什么吗 ?