打破并继续循环
- <!DOCTYPE html>
- <html>
- <body>
- <p>这个循环在 i=3 时跳过这一步:</p>
- <p id="demo"></p>
- <script>
- var text = "";
- var i;
- for (i = 0; i < 10; i++) {
- if (i === 3) { continue; }
- text += "数字是 " + i + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- </script>
- </body>
- </html>