How do I iterate through table rows and cells in JavaScript?

前端 未结 9 1016
旧时难觅i
旧时难觅i 2020-11-22 13:05

If I have an HTML table...say

<
9条回答
  •  不要未来只要你来
    2020-11-22 13:27

    This solution worked perfectly for me

    var table = document.getElementById("myTable").rows;
    var y;
    for(i = 0; i < # of rows; i++)
    {    for(j = 0; j < # of columns; j++)
         {
             y = table[i].cells;
             //do something with cells in a row
             y[j].innerHTML = "";
         }
    }
    

提交回复
热议问题
col1 Val1