JSFiddle - React, Tailwind, and code Playground

HTML

<span>From the end, move the cursor back this many spaces: </span><input type='text' id='num' size='5'/>
<button>Submit</button>
<br/><br/>
<textarea>The cursor will move in here</textarea>

CSS

textarea{width:100%;height:10em;}

JavaScript

$(document).ready(function() {
    $('button').click(function() {
       var myval = parseInt($('#num').val());
        //code to move cursor back - starting from the END OF THE STATEMENT
    });
});