TextNode °³Ã¼ÀÇ ±ÛÀÚ¼ö¸¦ ¹ÝȯÇÑ´Ù.
ÀÌ ¼Ó¼ºÀº ÀбâÀü¿ëÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.
°³Ã¼ | script | HTML | ±Ô°Ý | IE |
---|
ÀÌ ¼Ó¼ºÀº (¿µ¹®) W3C DOM Level 1(Document Object Model)¿¡¼ Á¤ÀǵǾú´Ù.
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>