while 循环

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h2>JavaScript while</h2>
  6.  
  7. <p id="demo"></p>
  8.  
  9. <script>
  10. var text = "";
  11. var i = 0;
  12. while (i < 10) {
  13. text += "<br>数字是 " + i;
  14. i++;
  15. }
  16. document.getElementById("demo").innerHTML = text;
  17. </script>
  18.  
  19. </body>
  20. </html>