±âÁ¸ÀÇ ÀÚ½Ä ¿¤·¹¸àÆ®¸¦ »õ·Î¿î ÀÚ½Ä ¿¤·¹¸àÆ®·Î ±³Ã¼ÇÑ´Ù.
¹Ýȯ°ª oVal´Â ±³Ã¼µÈ °³Ã¼¸¦ ÂüÁ¶ÇÑ´Ù.
±³Ã¼µÉ ³ëµå(node)´Â ¸ðüÀÇ Á÷Á¢ÀûÀÎ ÀÚ½ÄÀ̾î¾ß ÇÑ´Ù.
»õ·Î¿î ³ëµå´Â createElement ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© »ý¼ºÇÏ¿©¾ß ÇÑ´Ù.
ÀÌ ¸Þ¼µå´Â ·±Å¸ÀÓ(run time)¿¡ Á¢¼ÓÇÒ ¼ö ÀÖ´Ù. ·±Å¸ÀÓ¿¡¼ ÀÌ ¿¤·¹¸àÆ®°¡ Á¾·áűװ¡ ÆĽ̵DZâ Àü¿¡ Á¦°ÅµÇ¸é, ¹®¼ÀÇ Áö¿ªµéÀº Ç¥ÇöµÇÁö ¾ÊÀ» ¼ö ÀÖ´Ù.
IE6¿¡¼´Â ÀÌ ¸Þ¼µå°¡ attribute°³Ã¼µµ Àû¿ëµÈ´Ù.
ÀÌ ¸Þ¼µå´Â (¿µ¹®)DOM1(W3C Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
replaceChild ¸Þ¼µå·Î div ¼ÓÀÇ ÀÚ½Ä ¿¤·¹¸àÆ®¸¦ b¿Í i µÎ ¿¤·¹¸à·Î ±³Ã¼ÇÑ´Ù.
<HEAD> <SCRIPT> function replaceElement(){ var oChild=Div1.children(0); var textObj = oChild.innerHTML; if (oChild.tagName=='B'){ oNewChild=document.createElement('I'); Div1.replaceChild(oNewChild,oChild); oNewChild.innerHTML=textObj } else { oNewChild=document.createElement('B'); Div1.replaceChild(oNewChild,oChild); oNewChild.innerHTML=textObj } showA.innerHTML=Div1.children[0].nodeName; } </SCRIPT> </HEAD> <BODY> <DIV id=Div1 onclick="replaceElement()" style="border:solid 1 blue">¿©±â¸¦ Ŭ¸¯Çϸé <B>¿¤·¹¸àÆ®</B>°¡ ±³Ã¼µÈ´Ù.</DIV> <DIV>Div1.children[0].nodeName=<B><SPAN id=showA> <SCRIPT>document.write(Div1.children[0].nodeName)</SCRIPT> </SPAN></B></DIV> </BODY>