<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
</head>
<body>
<div id = "conter">
this is conter!!!
<input type="button" onclick="add_div()" value="添加" >
</div>
</body>
<script>
add_div = function(){
var ad=document.getElementById('conter');
var adiv=document.createElement('div');
ad.appendChild(adiv);
ad.appendChild(document.createTextNode("this is new"));
}
</script>
</html>
超简单的html动态添加div
最新推荐文章于 2024-03-07 13:50:16 发布