I am trying to delete the first row of a table using javascript.
My table is:
<table id="rankings-table" class="table">
<thead>
<tr>
<th>Ranking</th>
<th>Full name</th>
<th>points</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>dom</td>
<td>1,340</td>
</tr>
<tr>
<td>2</td>
<td>Naoimi</td>
<td>932</td>
</tr>
<tr>
<td>3</td>
<td>Sarah</td>
<td>1,120</td>
</tr>
</tbody>
</table>
and in javascript I am trying:
<script type="text/javascript">
const rankingsBody = document.querySelector('#rankings-table > tbody ');
function deleteRankings() {
console.log(rankingsBody);
rankingsBody.firstChild.remove();
//rankingsBody.removeChild(rankingsBody.firstChild);
}
document.addEventListener("DOMContentLoaded", () => { deleteRankings(); });
</script>
neither the remove() or removeChild() is working.
why? How do I make it work with rankingsBody variable?

rankingsBody.removeChild(rankingsBody.firstChild)- You have to pass the node to remove to.removeChild()console.log(rankingsBody.firstChild)<-- first child plays some mean tricks