<html>
<head>
<script>
function add_div(){
var div = document.createElement('div');
div.className='ds1';
var tex = document.createTextNode('hello');
div.appendChild(tex);
var done = document.getElementById('done');
done.appendChild(div);
}
</script>
<style>
.ds1{
height:80;
width:80;
background:red;
}
.dib{
height:600;
width:600;
background:yellow;
}
</style>
</head>
<body style="font-size:12pt;">
<a href="javascript:;" onclick="add_div();">create a new div</a>
<div id="done" class="dib"><div>
</body>
</html>
动态生成div子标签
最新推荐文章于 2022-09-29 16:00:19 发布