JSFiddle - React, Tailwind, and code Playground

by hollandben

HTML

<input type="text" value="Enter something" />

CSS

input {
    position:absolute;
    top:30px;
    left:30px;
    width: 300px;
    padding: 5px;
    color: #999;
}

JavaScript

$('input').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
        if (this.value == default_value) {
            this.value = '';
            $(this).css('color','#222');
        }
    });
    $(this).blur(function() {
        if (this.value == '') {
            $(this).css('color','#999');
            this.value = default_value;
        }
    });
});