<td>안에 이벤트로 this넘겨서 rowIndex 못 구하나요?

kknd345의 이미지

DHTML 에서 <td>안에 이벤트로 this넘겨서 rowIndex 못 구하나요?

보통
<tr onclick="functionName(this)">이렇게하면 자바쪽에서 this.rowIndex해서 row 가 몇 번 째 줄인가 알수 있잖아요

그런데 전

<tr>
<td><input type=button value="X" onClick="del(this)"></td>
</tr>

이런 식이거든요
버튼 클릭했을때 this 포인터 넘겨주면요 . 위에서 처럼 rowIndex 못 구하나요?

dsh의 이미지

td에는 rowIndex 속성이 없으니까요.

this.parentElement로 넘겨보세요.

익명 사용자의 이미지

function Table_SetValue( table, row, col, value )
{
        if( table )
        {
                if( row < table.rows.length )
                {
                        if( col < table.rows[row].cells.length )
                                table.rows[row].cells[col].innerHTML = value;
                }
        }
}