ÁöÁ¤µÈ À§Ä¡¿¡ ¿¤·¹¸àÆ®¸¦ »ðÀÔÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
sLoc
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, ¿¤·¹¸àÆ®¸¦ »ðÀÔÇÒ À§Ä¡¸¦ ³ªÅ¸³»´Â ¹®ÀÚ¿­ÀÌ´Ù.
beforeBegin ¿¤·¹¸àÆ® oElemÀ» °³Ã¼ÀÇ ¹Ù·Î Àü¿¡ »ðÀÔÇÑ´Ù.
afterBegin ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ ½ÃÀÛµÇ°í ¸ðµç ´Ù¸¥ ³»¿ëµé Àü¿¡ »ðÀÔÇÑ´Ù.
beforeEnd ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ Á¾·áµÇ±â Àü¿¡ ¸ðµç ´Ù¸¥ ³»¿ëµé ´ÙÀ½¿¡ »ðÀÔÇÑ´Ù.
afterEnd ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ Á¾·áµÈ ¹Ù·Î ´ÙÀ½¿¡ »ðÀÔÇÑ´Ù.
oElem
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, »ðÀ﵃ ÁöÁ¤µÈ ¿¤·¹¸àÆ® °³Ã¼ÀÌ´Ù.
¹Ýȯ°ª

¹Ýȯ°ª oObjÀº »ðÀÔµÈ ¿¤·¹¸àÆ® °³Ã¼ÀÌ´Ù.

Ư±â

¹®¼­°¡ ·ÎµùµÇ´Â µ¿¾È¿¡´Â »ðÀÔÇÒ ¼ö ¾ø´Ù.
ÀÌ ¸Þ¼­µå¸¦ »ç¿ëÇϱâ À§Çؼ­´Â onload°¡ ¹ß»ýµÉ ‹š±îÁö ±â´Ù·Á¾ß ÇÑ´Ù.

ÀÌ¹Ì ¹®¼­¿¡ Á¸ÀçÇÏ´Â °³Ã¼ÀÇ »ðÀÔÀ» ½ÃµµÇϸé, »õ·Î¿î °³Ã¼°¡ »ý¼ºµÇ´Â °ÍÀÌ ¾Æ´Ï°í, ±âÁ¸ °³Ã¼´Â insertAdjacentElement ¸Þ¼­µå¿¡¼­ ÁöÁ¤ÇÏ´Â À§Ä¡·Î À̵¿µÉ °ÍÀÌ´Ù.

Àû¿ë
°³Ã¼scriptIE
ÂüÁ¶
innerHTML outerHTML innerText outerText
insertAdjacentElement insertAdjacentHTML insertAdjacentText

  1. ¸ñ·Ï Ç׸ñ 1
  2. ¸ñ·Ï Ç׸ñ 2
  3. ¸ñ·Ï Ç׸ñ 3

insertAdjacentElement ¸Þ¼­µå¸¦ »ç¿ëÇÏ¿© ol °³Ã¼¿¡ »õ·Î¿î ¸ñ·Ï Ç׸ñÀ» 10°³±îÁö »ðÀÔÇÑ´Ù.

<HTML>
<HEAD>
<SCRIPT>
function doAdd(job){
  if (oList.children.length<10){
    var newObj=document.createElement('LI');
    if (job=='afterEnd') idx=oList.children.length-1;
    else idx=0;
    oList.children(idx).insertAdjacentElement(job,newObj);
    newObj.innerText='»õ Ç׸ñ '+oList.children.length;
  }
  showA.innerHTML='oList.children.length='+oList.children.length;
}
</SCRIPT>
</HEAD>
<BODY>
<OL id="oList">
<LI>¸ñ·Ï Ç׸ñ 1</LI>
<LI>¸ñ·Ï Ç׸ñ 2</LI>
<LI>¸ñ·Ï Ç׸ñ 3</LI>
</OL>
<BUTTON onclick="doAdd('BeforeBegin')">»ðÀÔ(BeforeBegin)</BUTTON>
<BUTTON onclick="doAdd('afterEnd')">»ðÀÔ(afterEnd)</BUTTON>
<DIV id=showA></DIV>
</BODY>
</HTML>