I am trying to have it so when I click on a word, it'll be marked out with a black background. Right now, I am wrapping each word in a sentence in its own span, but I would like to create a span for each word in a block of text. Any ideas on how to go about doing that?
Here is my code right now
document.querySelectorAll('span').forEach(span=>
span.onclick = () => {
span.style.background = '#000';
})
HTML
<span>these </span>
<span>are </span>
<span>some </span>
<span>words </span>
<span>for </span>
<span>a </span>
<span>test </span>