'How do I make an event Listener (onclick) for a single Table Cell
My question is: How can I make a table cell, for example, change text on click? I tried this:
function randomFunction() {
document.getElementById("randomId").innerText = "random text"
}
<table>
<tr>
<td id="randomId" onclick="randomFunction()">random text</td>
</tr>
</table>
But it does the onclick attribute for the entire row.
Is it possible to trigger the function only when I click on the cell ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
