TextNode °³Ã¼ÀÇ ±ÛÀÚ¼ö¸¦ ¹ÝȯÇÑ´Ù.

Àμö
: (¼Ó¼º Á¤¼ö°ª)
¼Ó¼º°ªÀº TextNode °³Ã¼ÀÇ ±ÛÀÚ¼ö¸¦ ³ªÅ¸³»´Â Á¤¼ö°ªÀÌ´Ù.

ÀÌ ¼Ó¼ºÀº ÀбâÀü¿ëÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.

Àû¿ë
°³Ã¼scriptHTML±Ô°ÝIE
Âü°í

ÀÌ ¼Ó¼ºÀº (¿µ¹®) W3C DOM Level 1(Document Object Model)¿¡¼­ Á¤ÀǵǾú´Ù.


  1. ¸ñ·ÏÀÇ Ã¹ ¹®ÀåÀ» ¹Ý¾¿ Àß¶ó¼­ »õ·Î¿î ¸ñ·Ï Ç׸ñÀ» ¸¸µç´Ù.
°á°ú Ç¥½Ãâ

TextNode °³Ã¼¿¡¼­ splitText ¸Þ¼­µå¸¦ »ç¿ëÇÏ¿© ù ¸ñ·ÏÀÇ ¹®ÀÚ¿­À» ¹Ý¾¿ À߶ó »õ·Î¿î Ç׸ñÀ» ¸¸µç´Ù.

<SCRIPT>
function cutHalf(){
  str='';
  if (olObj.firstChild.innerText.length){
    newLI=document.createElement('LI');
    olObj.appendChild(newLI);
    fullStr=olObj.firstChild.childNodes(0);
    halfStr=fullStr.splitText(fullStr.length/2);
    newLI.appendChild(halfStr);
    showA.innerText=olObj.outerHTML;
  }
}
</SCRIPT>
<OL id=olObj onclick="cutHalf()">
<LI>¸ñ·ÏÀÇ Ã¹ ¹®ÀåÀ» ¹Ý¾¿ Àß¶ó¼­ »õ·Î¿î ¸ñ·Ï Ç׸ñÀ» ¸¸µç´Ù.
</OL>
<XMP id=showA style="border:solid 1 blue;width:500">°á°ú Ç¥½Ãâ</XMP>