<html> <head> <script> function test(){ var one =document.getElementById("one"); var img = document.createElement("img"); img.src="7.jpg"; img.alt="美女"; var a = document.createElement("a"); a.href="http://www.google.com.hk"; a.appendChild(img); one.appendChild(a); } function remove(){ var one =document.getElementById("one"); var children = one.childNodes; one.removeChild(children[children.length-1]); } </script> </head> <body> <div id="one"></div> <a href="javascript:test()">add</a> <a href="javascript:remove()">del</a> </body> </html>