首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:Javascript 教程
TRY RUN / 在线示例
Javascript 教程 For 循环
Javascript 教程 For 循环
源代码
运行
<!DOCTYPE html> <html> <body> <p>Click the button to loop through a block of code five times.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x="",i; for (i=0;i<5;i++) { x=x + "The number is " + i + "<br>"; } document.getElementById("demo").innerHTML=x; } </script> </body> </html>
运行结果