搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
JavaScript 教程
JavaScript基础教程
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>JavaScrip twhile continue语句使用示例 - 基础教程(div.cn)</title> <body> <p>单击按钮开始循环,该循环将跳过i等于3的步骤:</p> <button onclick="myFunc()">Click</button> <p id="result"></p> <script> function myFunc() { var text = ""; var i = 0; while (i < 6) { i++; if (i === 3) { continue; } text += "The number is " + i + "<br>"; } document.getElementById("result").innerHTML = text; } </script> </body> </html>
运行结果