<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>修改html DOM内容</title>
</head>
<body>
<div class="div1">
hello div
</div>
<input type="button" value="add" id="add">
<script>
var ele=document.getElementById('add');
ele.onclick=function () {
var div1=document.getElementsByClassName('div1')[0];
var img=document.createElement('img');
// img.setAttribute('src','1.jpg');
img.src='1.jpg';//DHTML ,增强html
div1.appendChild(img);
}
</script>
</body>
</html>