简单教程
提交运行
代码编辑器:
<p>点击按钮执行循环,在 i 等于 3 时跳过当前循环</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var text = ""; var i = 0; while (i < 5) { i++; if (i == 3) { continue; } text += "<br>The number is " + i; } document.getElementById("demo").innerHTML = text; } </script>
运行结果: