使用for循环向页面中输出一个 h1-h6运行后的标签效果
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
for (var i = 1; i <= 6; i++) {
document.write("<h" + i + ">Heading " + i + "</h" + i + ">");
}
</script>
</body>
</html>
运行这段代码后,页面中会依次输出 h1 到 h6 标签,效果如下:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
原文地址: https://www.cveoy.top/t/topic/hBx0 著作权归作者所有。请勿转载和采集!