Å×À̺í ÁÙ(tr)¿¡ »õ·Î¿î Å×À̺í Ä(cell: th ȤÀº td)À» »ðÀÔÇÏ°í cells Ä÷º¼Ç¿¡ ÄÀ» »ðÀÔÇÑ´Ù.
ÄÀÇ »ðÀÔÀº cells Ä÷º¼ÇÀÇ Á¦ÀÏ µÚ¿¡ Ãß°¡ÇÏ´Â °ÍÀÌ ¹Ù¶øÁ÷ÇÏ´Ù. ÀÌ ¹æ½ÄÀÌ ÄÀ» Áß°£¿¡ »ðÀÔÇÏ´Â °Íº¸´Ù ºü¸£´Ù. ÄÀ» Ä÷º¼ÇÀÇ Á¦ÀÏ µÚ¿¡ »ðÀÔÇÏ·Á¸é, °ªÀ» µðÆúÆ®ÀÎ -1·Î ¼³Á¤Çϰųª, Ä÷º¼ÇÀÇ ±æÀÌ¿¡¼ 1À» »« À§Ä¡·Î ÁöÁ¤ÇÏ¸é µÈ´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¾î)DOM Level 1(Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
¿¹Á¦ Ä1-1 | ¿¹Á¦ Ä1-2 |
¿¹Á¦ Ä2-1 | ¿¹Á¦ Ä2-2 |
insertCell ¸Þ¼µå·Î tr¿¡ ÄÀ» Ãß°¡ÇÏ°í, deleteCell ¸Þ¼µå·Î Ä(td)À» »èÁ¦ÇÑ´Ù.
<TABLE id=tableObj border=1 width=600> <TR id=row1> <TD id=cell11>¿¹Á¦ Ä1-1</TD> <TD id=cell12>¿¹Á¦ Ä1-2</TD> </TR> <TR id=row2> <TD id=cell21>¿¹Á¦ Ä2-1</TD> <TD id=cell22>¿¹Á¦ Ä2-2</TD> </TR> </TABLE> <SCRIPT> function makeCell(){ newTd=row1.insertCell(document.createElement('<TD>')) newTd.innerText='»ý¼º, »ðÀÔµÈ Ä'; } function delCell(){ row1.deleteCell(0); } </SCRIPT> <BUTTON onclick="delCell();">Å×À̺í Ä Á¦°Å Ŭ¸¯</BUTTON> <BUTTON onclick="makeCell();">Å×À̺í Ä »ý¼º Ŭ¸¯</BUTTON>