JSFiddle - React, Tailwind, and code Playground

by Prajeesh_PR

HTML

<input type="text" id="test">

JavaScript

document.getElementById("test").addEventListener("click", function select(e) {
    var input = this;
    var s = input.value;
    if (s.length) {
        window.setTimeout(function() {
            input.setSelectionRange(s.length-1, s.length);
        }, 0);
    }
}, false);