JSFiddle - React, Tailwind, and code Playground

HTML

<button class="tblButton">Hi</button>
<button class="tblButton">Hi again</button>

JavaScript

var txt = "fred";
var atext = "hello" + txt;

function sayHello(atext) {
    alert(atext);
}
$('.tblButton').on('click', function() {
    sayHello(atext);
});
$('.tblButton').eq(0).click();//fires with the fred
txt = "Johnny";

atext = 'hello' + txt;
$('.tblButton').eq(1).click();