テーブルの行をループして、column2
セルに値が含まれていないか空のセルが含まれている場合にのみ、背景色の変更を実行したいと考えています。これは私が今持っているものですが、すべての行に色が付けられており、セルcolumn2
が空の場合にのみロジックを適用する必要があります。
JS:
// loops through rows
for (var i = 0; rows; rows = tbody.rows[i]; i++) {
//loops through cells
for (var j = 1; col; col = rows.cells[j]; j++) {
//gets cells of current row
cells = rows[i].getElementsByTagName('td');
//gets cells of col 1
ocells = rows.cells[j].getElementByTagName('td');
while (rows.cells[j] === null) {
//condition here>>
}
}
}
HTML:
<div id="table">
<table name="tbody" id="tbody1">
<tr>
<td>col1 Val1</td>
<td>col2 Val2</td>
</tr>
<tr>
<td>col1 Val3</td>
<td>col2 Val4</td>
</tr>
</table>
</div>
どんな助けでも大歓迎です!