javascript基础之循环
//while循环 <script type="text/javascript"> i = 1; while (i <= 6) { document.write("<h" + i+">这是标题"+i); document.write("</h"+i+">"); i++; } </script>
//do_whilel循环 <script type="text/javascript"> i = 1; do { document.write("<h" + i+">这是标题"+i); document.write("</h"+i+">"); i++; } while(i<=6); </script>
//for循环 <script type="text/javascript"> for(i=1;i<=6;i++) { document.write("<h"+i+">这是标题"+i); document.write("</h"+i+">"); } </script>
结果:
这是标题1
这是标题2
这是标题3
这是标题4
这是标题5
这是标题6