table¿¡¼­ ÁÙµéÀÇ Ä÷º¼Ç rows¿¡¼­ °³Ã¼ÀÇ À§Ä¡¸¦ ¹ÝȯÇÑ´Ù.

Àμö
: (¼Ó¼º Á¤¼ö°ª)
¼Ó¼º°ªÀº ÁÙµéÀÇ Ä÷º¼Çrows¿¡¼­ °³Ã¼ÀÇ À§Ä¡¸¦ ³ªÅ¸³»´Â Á¤¼ö°ªÀÌ´Ù. ÀÌ´Â Àμö(index)ÀÌ´Ù.

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

Ư±â

ÀÌ ¼Ó¼ºÀº tBody, tHead³ª tFoot rows Ä÷º¼Ç¿¡¼­ °³Ã¼ÀÇ À§Ä¡¸¦ ³ªÅ¸³»´Â sectionRowIndex¼Ó¼º°ú´Â ´Ù¸£´Ù. ÀÌ ºÎºÐµéÀº tr°¡ Ç×»ó À̵é ÁßÀ̳ª table¿¡ Æ÷ÇÔÇϵµ·Ï »óÈ£ ÀÛ¿ëÇÑ´Ù. °³Ã¼ÀÇ rowIndex ¼Ó¼ºÀ» ¿øõ HTML ¹®¼­¿¡¼­ ³ªÅ¸³ª´Â ¼ø¼­·Î ¾òÀ» ¼ö ÀÖ´Ù.

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

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


td 11td 12td 13
td 21td 22td 23
td 31td 32td 33
td 41td 42td 43

tableÀÇ rowIndex¸¦ »ç¿ëÇÏ¿© ¦¼öÁÙ°ú Ȧ¼öÁÙÀ» ´Ù¸£°Ô »ö»óÀ» ³Ö¾ú´Ù.

<TABLE id=tableObj bgColor='pink' width=300 cellpadding=3 cellspacing=10>
<TR>
<TD>td 11</TD><TD>td 12</TD><TD>td 13</TD>
</TR>
<TR>
<TD>td 21</TD><TD>td 22</TD><TD>td 23</TD>
</TR>
<TR>
<TD>td 31</TD><TD>td 32</TD><TD>td 33</TD>
</TR>
<TR>
<TD>td 41</TD><TD>td 42</TD><TD>td 43</TD>
</TR>
</TABLE>
<SCRIPT>
function paintTable(){
  var rows=tableObj.rows;
  for(var i=0;i<ROWS.length;i++){
    if(i%2==0) {
      rows[i].style.backgroundColor='blue';
      rows[i].style.color='yellow';
      rows[i].style.fontWeight='bold';
    } else {
      rows[i].style.backgroundColor='yellow';
      rows[i].style.color='blue';
    }
  }
}
</SCRIPT>
<BUTTON onclick="paintTable()">Å×À̺íÀÇ ¾ç½ÄÈ­</BUTTON>