源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <p>點擊下面的按鈕來執行循環,該循環會跳過 i=3 的步進。</p> <button onclick="myFunction()">點擊這里</button> <p id="demo"></p> <script> function myFunction(){ var x="",i=0; for (i=0;i<10;i++){ if (i==3){ continue; } x=x + "該數字為 " + i + "<br>"; } document.getElementById("demo").innerHTML=x; } </script> </body> </html>
運行結果