JSFiddle - React, Tailwind, and code Playground

HTML

<button class="textButton">My Text</button>
<br/>
<input type="button" label="aaa" class="textButton" value="Text Button #2"/>

JavaScript

$(document).ready(function() {
    $(".textButton").click(function() {
        var me = $(this);
        
        me.hide();
        me.after("<input id='tmpInput'/>");
        $("#tmpInput").focus();
        $("#tmpInput").bind("keyup", function(e) {
            e.preventDefault();
            if (e.keyCode == '13') {
                var value = $(this).val();
                $(this).remove();
                if(me.is("input")) {
                    me.text(value);
                } else if(me.is("button")) {
                    me.text(value);
                }
                me.show();
            }
            return false;
        });
    });
});