I have an HTML table where data is being displayed from the data table and where a function is being assigned with the use of an ID TAG that hides the <td> with the ID private-mode when you click on the button.
but the function only seems to work for the first row and not for the other rows I have checked the other rows with the inspect element function in chrome and they all have the ID private-mode
Can someone explain to me why its not working for the other rows?
Button:
<button onclick="privatemode()">Private mode</button>
html-table:
<div class="cards card">
<table class="table hoverTable">
<tr>
<th></th>
<th>Omschrijving</th>
<th>Bedrijf</th>
<th>Betaalmethode</th>
<th>Bedrag</th>
</tr>
<!-- PHP CODE TO FETCH DATA FROM ROWS -->
<?php
// LOOP TILL END OF DATA
while($rows=$result->fetch_assoc())
{
?>
<tr>
<!-- FETCHING DATA FROM EACH
ROW OF EVERY COLUMN -->
<th><input class="checkbox1" type="checkbox"></th>
<td><?php echo $rows['Omschrijving'];?></td>
<td><?php echo $rows['Bedrijf'];?></td>
<td><?php echo $rows['Betaalmethode'];?></td>
<td id="private-mode"><?php echo $rows['Bedrag'];?></td>
</tr>
<?php
}
?>
</table>
</div>
Javascript:
function privatemode() {
var x = document.getElementById("private-mode");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}