Here is the basic table:
<table>
<tbody>
<tr>
<td style="color: #ff00ff; background-color: #ffffff">Q</td>
<td style="background-color: #442244; color: #442244">Y</td>
<td style="color: #ffff00; background-color: #442244">A</td>
</tr>
<tr>
<td style="color: #ffeefe; background-color: #990000">Q</td>
<td style="color: #ffff00; background-color: #ff0">M</td>
<td style="color: #000000; background-color: #ff7777">O</td>
</tr>
</tbody>
</table>
I am trying to collect value of color and background-color of each TD to compare if they match or not. However in absence of ID or Class, I'm having a hard time traversing the table using DOM. Any suggestions would be greatly appreciated!!
For example, I would use getElementsByTagName('td')
to collect all 6 TDs however, I could not read into each for it's style. I could not convert into array. querySelectorAll('td')
produced an empty NodeList. I would try table = document.getElementsByTagName('table')
and then table.getElementsByTagName('td')
which gives me "table.getElementsByTagName is not a function" error. So I am stumped after doing researches and trying to understand best ways to traverse the table using DOM. Since I hit a wall, I'm trying stackoverflow.