document.createDocumentFragment() 예제
<ul> <li>홈짱닷컴</li> <li>Homzzang.com</li> <li>2012</li> </ul> <button onclick="homzzang()">클릭</button> <script> function homzzang() { var d = document.createDocumentFragment(); d.appendChild(document.getElementsByTagName("LI")[0]); d.childNodes[0].childNodes[0].nodeValue = "홈페이지 제작관리"; document.getElementsByTagName("UL")[0].appendChild(d); } </script> 결과보기
<ul>
<li>홈짱닷컴</li>
<li>Homzzang.com</li> <li>2012</li>
</ul>
<button onclick="homzzang()">클릭</button>
<script>
function homzzang() {
var d = document.createDocumentFragment();
d.appendChild(document.getElementsByTagName("LI")[0]);
d.childNodes[0].childNodes[0].nodeValue = "홈페이지 제작관리";
document.getElementsByTagName("UL")[0].appendChild(d);
}
</script>
결과보기