반복문으로 가져오는 법
let rowIndex;
let cellIndex;
rows.forEach((row, ri)=>{
row.forEach((cell, ci)=>{
if(cell === event.target){ //이벤트 타겟과 일치하는 태그
rowIndex = ri;
cellIndex = ci;
}
});
});
테이블 자체에서 제공되는 cellIndex, rowIndex를 이용하는 법
let rowIndex = event.target.parentNode.rowIndex;
let cellIndex = event.target.cellIndex;
위와같이 인덱스를 사용하면 반복문을 돌려가며 찾지 않아도 된다.