W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击按钮从 1 到 6 循环,以生成 HTML 标题。</p> <button onclick="myFunction()">试一试</button> <div id="demo"></div> <script> function myFunction() { var x ="", i; for (i=1; i<=6; i++) { x = x + "<h" + i + ">标题 " + i + "</h" + i + ">"; } document.getElementById("demo").innerHTML = x; } </script> </body> </html>