首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:Javascript 教程
TRY RUN / 在线示例
Javascript 教程 循环输出 HTML 标题
Javascript 教程 循环输出 HTML 标题
源代码
运行
<!DOCTYPE html> <html> <body> <p>Click the button to loop from 1 to 6, to make HTML headings.</p> <button onclick="myFunction()">Try it</button> <div id="demo"></div> <script> function myFunction() { var x="",i; for (i=1; i<=6; i++) { x=x + "<h" + i + ">Heading " + i + "</h" + i + ">"; } document.getElementById("demo").innerHTML=x; } </script> </body> </html>
运行结果