JSFiddle - React, Tailwind, and code Playground
by Aleksey Karagodnikov
HTML
<input id="mail" type="text" onfocus="removeBackground(this);" onblur="addBackground(this);" value="" />
CSS
#mail {
background: url(http://i.imgur.com/pCbyu2p.png) no-repeat 10px center;
height: 25px;
width: 350px;
}
JavaScript
function removeBackground(x) {
x.style.background = "white";
}
function addBackground(x) {
if (x.value === "") {
x.style.background = "url(http://i.imgur.com/pCbyu2p.png) no-repeat 10px center";
} else {
removeBackground(x);
}
}