JSFiddle - React, Tailwind, and code Playground

by prankol57

HTML

<input  type="number" />
<div id="test">
</div>

JavaScript

(function($) {
    $.fn.caretPosition = function() {
        if (!this.length) return;
        var input = this[0];
        try {
          return input.selectionStart;
        } catch(e) {
          // No need for old IE support
          return 0;
        }
    }
})(jQuery);
    $("input").keyup(function() {
        $("<p>")
        .html("Cursor position at " + $("input").caretPosition())
        .appendTo("#test");
    });