下面的JS代码可以在网页中输出
到
大小的html标签文本
<!DOCTYPE html>
<html>
<body>
<p>75271.com 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>
<!DOCTYPE html> <html> <body> <p>75271.com 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>