JSFiddle - React, Tailwind, and code Playground

HTML

<button id="one">one</button>
<button id="two">two</button>
<button id="three">three</button>
<button id="four">four</button>

JavaScript

var tabs = ['one', 'two', 'three', 'four'];

$.each(tabs, function(idx, tab) {
    $("#" + tab).on("click", function() {
        alert(idx);
    })
});