JSFiddle - React, Tailwind, and code Playground

by wookiehangover

HTML

<script src="https://github.com/Modernizr/Modernizr/raw/master/modernizr.js"></script>
<input type="text" placeholder="PLACEHOLD ME!"/>

JavaScript

$.fn.placehold_me = function(){
    return this.each(function() {
        var $this = $(this),
            val = $this.attr('placeholder');
        
        if( $this[0].nodeName !== "INPUT" ) return false;
        
        $this
            .attr('title', val)
            .val(val)
            .focus(function(){
              if( $this.attr('title') == val ) $this.val("");
            })
            .blur(function(){
              if( $this.val() === "" ) $this.val(val);
            });
    });
};

if (!Modernizr.input.placeholder){
    $('input[type="text"]').placehold_me();
}