<html>
<body>
<p>该实例中, continue 语句用在了标签引用上。在 j 等于 12 时,会跳过 "Loop2" 的当前迭代,并执行下一个迭代。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction() {
var text = "";
var i, j;
Loop1: // 第一个循环标签 "Loop1"
for (i = 0; i < 3; i++) {
text += "<br>" + "i = " + i + ", j = ";
Loop2: // 第二个循环标签 "Loop2"
for (j = 10; j < 15; j++) {
if (j == 12) {
continue Loop2;
}
document.getElementById("demo").innerHTML = text += j + " ";
}
}
}
</script>
</body>
</html>