JavaScript do while循环的用法代码实例,从1输出5个数字,循环输出,循环的用法当然是比较普遍的,不管是JS还是ASP/PHP/JSP等都有循环的使用。 演示代码: <html> <head> <title>do while循环</title> </head> <body> <center><h2>测试do while循环</h2></center> <hr> <script language="JavaScript"> // 变量声明 var i = 1; var intTotal = 0; // 循环语句 do{ document.write("数字: " + i + "<br>"); intTotal += i; i++; } while (i <= 5); document.write("<hr>总和: " + intTotal + "<br>"); </script> </body> </html <br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 JavaScript 关于 if else 条件判断的语句实战Dreamweaver MX技巧之超链接