JSFiddle - React, Tailwind, and code Playground
HTML
<span>Hello</span>
<input type="text" style="display:none;" value=""/>
CSS
span, input {
font-family: arial, sans-serif;
font-size: 14px;
}
span {
cursor: pointer;
}
input {
margin-left: -2px;
margin-top: -2px;
}
JavaScript
$(function() {
$("span").click(function() {
$(this).hide();
$("input").val($(this).text()).show();
});
$("input").keypress(function(e) {
if (e.which == 13) {
$(this).hide();
$("span").text($(this).val()).show();
}
});
});