i am trying to select the next td and add a class to it by using nextSibling but it doesn't seem to work.
const player2pos = document.querySelector("#player2-race .active");
player2pos.nextSibling.classList.add("active");
what i get:
Uncaught TypeError: Cannot read property 'add' of undefined at HTMLDocument.
when i console.log(document.querySelector("#player2-race .active")), it shows that i selected the right td. can someone tell me what i am doing wrong?
EDIT: here is the html
<tr id="player2-race">
<td></td>
<td></td>
<td></td>
<td class="active"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>