JSFiddle - React, Tailwind, and code Playground
HTML
<div class="button one">Button 1</div>
<div class="button two">Button 2</div>
<div class="button three">Button 3</div>
CSS
.button {
background: lightblue;
padding: 20px;
margin: 20px;
}
JavaScript
var theButtons = ['.button.one', '.button.two', '.button.three'];
for (i=0; i<theButtons.length; i++) {
$(theButtons[i]).click(function () {
alert(i);
});
}