ÁöÁ¤µÈ À§Ä¡¿¡ ¿¤·¹¸àÆ®¸¦ »ðÀÔÇÑ´Ù.
beforeBegin | ¿¤·¹¸àÆ® oElemÀ» °³Ã¼ÀÇ ¹Ù·Î Àü¿¡ »ðÀÔÇÑ´Ù. |
afterBegin | ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ ½ÃÀÛµÇ°í ¸ðµç ´Ù¸¥ ³»¿ëµé Àü¿¡ »ðÀÔÇÑ´Ù. |
beforeEnd | ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ Á¾·áµÇ±â Àü¿¡ ¸ðµç ´Ù¸¥ ³»¿ëµé ´ÙÀ½¿¡ »ðÀÔÇÑ´Ù. |
afterEnd | ¿¤·¹¸àÆ® oElemÀ» °³Ã¼°¡ Á¾·áµÈ ¹Ù·Î ´ÙÀ½¿¡ »ðÀÔÇÑ´Ù. |
¹Ýȯ°ª oObjÀº »ðÀÔµÈ ¿¤·¹¸àÆ® °³Ã¼ÀÌ´Ù.
¹®¼°¡ ·ÎµùµÇ´Â µ¿¾È¿¡´Â »ðÀÔÇÒ ¼ö ¾ø´Ù.
ÀÌ ¸Þ¼µå¸¦ »ç¿ëÇϱâ À§Çؼ´Â onload°¡ ¹ß»ýµÉ ‹š±îÁö ±â´Ù·Á¾ß ÇÑ´Ù.
ÀÌ¹Ì ¹®¼¿¡ Á¸ÀçÇÏ´Â °³Ã¼ÀÇ »ðÀÔÀ» ½ÃµµÇϸé, »õ·Î¿î °³Ã¼°¡ »ý¼ºµÇ´Â °ÍÀÌ ¾Æ´Ï°í, ±âÁ¸ °³Ã¼´Â insertAdjacentElement ¸Þ¼µå¿¡¼ ÁöÁ¤ÇÏ´Â À§Ä¡·Î À̵¿µÉ °ÍÀÌ´Ù.
°³Ã¼ | script | IE |
---|
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>