javascript怎么创建div
1 回答
元芳怎么了
TA贡献1798条经验 获得超7个赞
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function createDIV(){
var div=document.createElement("div");//创建一个DIV
div.innerHTML="this is a div";//设置div里面的内容
document.body.appendChild(div); //主要加上这句,把新建的DIV加到页面上。
}
</script>
<body onload="createDIV()">
</body>
</html>
- 1 回答
- 0 关注
- 900 浏览
添加回答
举报
0/150
提交
取消