I've started to learn JavaScript not long ago.
I have several td elements in HTML and when I click on one of them, I would like to get it's innerHTML in JS. (Vanilla JS)
<div class="calendarCont">
<table>
<tr>
<td>Jan</td>
<td>Feb</td>
<td>Mar</td>
<td>Apr</td>
</tr>
<tr>
<td>May</td>
<td>Jun</td>
<td>Jul</td>
<td>Aug</td>
</tr>
</table>
</div>
I already know this method :
<td onclick="clickedCell = this.innerHTML; console.log(clickedCell)>Jan</td>
But what I'm looking for is a function with an addEventListener if it is possible, but I'm open to any suggestions.
Thank you.