This question already has an answer here:
So say I have this HTML
<div class="board">
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
<button type="button" class="space"></button>
</div>
In javascript I have this
const changeSpot = () => {
this.textContent = "You clicked me!";
}
const spots = document.getElementsByClassName('space');
How do I make it so that changeSpot() can reference the button that is using it? I tried adding onclick="changeSpot" on the buttons however that doesnt seem to work. If it matters, the javascript functions are located in a module called gameBoard. Thanks for looking!