js动态向html添加数据。

.innerHTML  各种标签的地方插入
.write   在当前的位置进行写入。可能是某个动态计算后的结果。但是不在head中写入。

<html>
<head>
<script>
alert("aaa");
document.getElementsByTagName("div")[0].innerHTML+="aaa";
document.write("aaa")
</script>
</head>
<body>
<div></div>
<div style="font-size:100px">
<script>
alert("bbb");
document.getElementsByTagName("div")[0].innerHTML+="bbb";
document.write("bbb")
</script>
</div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/rubikchen/article/details/85331632
今日推荐