JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" id="testA" name="test">testA</a>
<a href="#" id="testB" name="test">testB</a>
<div id="showA">showA</div>
<div id="showB">showB111</div>
JavaScript
var arr = ["A","B"];
for(var i=0;i<arr.length;i++) {
(function (i) {
$("#test"+arr[i]).click(function(){
alert($("#show"+arr[i]).text())
});
}(i));
}