JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="password" value="Password" class="placeholder" />
CSS
.placeholder { color: #a3a3a3; }
JavaScript
$(function () {
$('#password').focus(function () {
this.type = 'password'
$(this).removeClass('placeholder').val(function () {
var val = $.trim(this.value);
return (val == 'Password')?'':this.value;
});
}).blur (function () {
$(this).val(function () {
var val = $.trim(this.value);
return (val == '')?'Password':this.value;
});
if (this.value == 'Password') {
$(this).addClass('placeholder')
this.type = 'text';
}
});
});