<div class="htmlarea"> <textarea id="runcode77886"> <style> .aaa { border:1px solid #ccc; background:#f60; height:200px; } </style> <div id="tlink" style="cursor:pointer;"> </div>테스트해 보세요 </textarea> <br><input onclick="runEx('runcode77886')" type="button" value="运行代码"><input onclick="doCopy('runcode77886')" type="button" value="复制代码"> <input onclick="doSave(runcode77886)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 </div>]<script type="text/javascript"> function cdiv(){ var createDiv = document.createElement("div"); createDiv.setAttribute("class","aaa") //createDiv.style.border = "1px solid #ccc"; //createDiv.style.background = "#f60"; //createDiv.style.height = "200px;"; var createText = document.createTextNode("我是一个层"); createDiv.appendChild(createText); var tlink = document.getElementById("tlink"); //alert(tlink); insertAfter(createDiv,tlink); } function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if(parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } } window.onload = function(){ tlink.onclick=function() { cdiv(); } } </script>