javascript怎么創(chuàng)建div
javascript怎么創(chuàng)建div?
慕運(yùn)維8079593
2019-02-07 15:07:18
TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無(wú)標(biāo)題文檔</title>
</head>
<script type="text/javascript">
function createDIV(){
var div=document.createElement("div");//創(chuàng)建一個(gè)DIV
div.innerHTML="this is a div";//設(shè)置div里面的內(nèi)容
document.body.appendChild(div); //主要加上這句,把新建的DIV加到頁(yè)面上。
}
</script>
<body onload="createDIV()">
</body>
</html>
舉報(bào)