zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 JAVASCRIPT开发学习:while 循环

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <p>点击下面的按钮,只要 i 小于 5 就一直循环代码块。</p>
    <button onclick="myFunction()">点击这里</button>
    <p id="demo"></p>
    <script>
    function myFunction(){
        var x="",i=0;
        while (i<5){
            x=x + "该数字为 " + i + "<br>";
            i++;
        }
        document.getElementById("demo").innerHTML=x;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <p>点击下面的按钮,只要 i 小于 5 就一直循环代码块。</p>
    <button onclick="myFunction()">点击这里</button>
    <p id="demo"></p>
    <script>
    function myFunction(){
        var x="",i=0;
        do{
            x=x + "该数字为 " + i + "<br>";
            i++;
        }
        while (i<5)  
        document.getElementById("demo").innerHTML=x;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    cars=["BMW","Volvo","Saab","Ford"];
    var i=0;
    for (;cars[i];){
        document.write(cars[i] + "<br>");
        i++;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    cars=["BMW","Volvo","Saab","Ford"];
    var i=0;
    while (cars[i]){
        document.write(cars[i] + "<br>");
        i++;
    }
    </script>
    
    </body>
    </html>

  • 相关阅读:
    Node 基本配置
    python GIL锁
    大数据 Zookeeper 集群
    大数据 Hadoop HA
    python 内置方法使用
    Linux Curl使用
    Linux 文件解压缩
    大数据 Hadoop 常见端口
    大数据 Hadoop 集群安装
    css结构设计思想
  • 原文地址:https://www.cnblogs.com/tszr/p/10942434.html
Copyright © 2011-2022 走看看