<script type="text/javascript"> function append(event){ var myhref = document.createElement("input"); myhref.value="http://cnblogs.com"; myhref.className ="myhref"; document.body.appendChild(myhref); } document.getElementById("mydel").onclick=function remove(){ var a = document.getElementsByClassName("myhref"); if (a.length>0) a[0].parentNode.removeChild(a[0]); } </script>
原文:http://www.cnblogs.com/z5337/p/5107400.html