JSFiddle - React, Tailwind, and code Playground
by Sumner Evans
HTML
<span class='text'>0</span>
<span class='text'>1</span>
<span class='text'>2</span>
<span class='text'>This works with any content</span>
CSS
.text{
width:20px;
height:20px;
border:1px solid black;
}
JavaScript
var textSpans=document.querySelectorAll('span.text');
for (i in textSpans)
{
textSpans[i].onclick=function(e) {alert(e.target.innerHTML);};
}