JSFiddle - React, Tailwind, and code Playground

by abhitalks

HTML

<input id="txt" class="clear" value ="example.company.com" />
<br />

JavaScript

jQuery.fn.cleardefault = function() {
    return this.focus(function(e) {
        if( this.value == this.defaultValue ) {
            this.value = ".company.com";
            var t = this;
            window.setTimeout(function() {
                t.setSelectionRange(0,0);
                //t.setCursorPosition(0);
            }, 0);
        }
    }).blur(function(e) {
        if( !this.value.length ) {
            this.value = this.defaultValue;
            
        }
    });
};


jQuery(".clear").cleardefault();