JSFiddle - React, Tailwind, and code Playground
HTML
<span>Some words here</span>
<br>
<span>Some more words here</span>
CSS
body,
input {
font-size: 40px;
}
JavaScript
(function outer() {
var span = document.querySelectorAll('span'),
text = document.createElement("input");
var changeMethods = {
changeIt: function() {
document.body.replaceChild(text, this);
text.value = this.innerHTML;
text.select();
},
saveIt: function() {
span.innerHTML = this.value;
document.body.replaceChild(span, this);
}
};
for (let i = 0; i < span.length; i += 1) {
span[i].addEventListener('click', changeMethods.changeIt);
}
for (let i = 0; i < text.length; i += 1) {
text[i].addEventListener('blur', changeMethods.saveIt);
}
}());