JSFiddle - React, Tailwind, and code Playground

HTML

<button>Button</button>

CSS

button {
    height: 30px;
    width: 80px;
}

JavaScript

function toggleTxt(elem, anotherTxt) {
    var txt = elem.text();
    
    elem.click(function(){
        if( $(this).text() == txt ) {
            $(this).text(anotherTxt);
        } else {
            $(this).text(txt);
        }
    });
};

toggleTxt($("button"), "some word");