JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="ostemad">
<input type="text" value="banan">
<input type="text" value="leverhørmer">
<input type="text" value="abemad">
<input type="text" value="hotdog">
CSS
input[type="text"] { color: #aaa; }
input.selected { color: #000; }
JavaScript
$("input[type=text]").each(
function(i,elm) {
var $this = $(this),
val = $this.val();
$this
.focus(function(e) {
$this
.val('')
.addClass("selected");
})
.blur(function(e) {
if($this.val() == "") {
$this
.val(val)
.removeClass("selected");
}
});
}
)