<html>
<body>
<p>该实例中,break 语句用在了引用标签"Loop2"上。在 j 等于 12 时,break 语句用于跳出 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) {
break Loop2;
}
document.getElementById("demo").innerHTML = text += j + " ";
}
}
}
</script>
</body>
</html>