JSFiddle - React, Tailwind, and code Playground

by JCMais

HTML

<input type="text" id="title" name="title" value="[titulo][/titulo]">

JavaScript

var cursorAt = function( el, pos ){
    
        if( ++el.selectionStart ) {
            
            el.focus(); 
            el.setSelectionRange( pos, pos );
            
        } else if( el.createTextRange ) { /* IE */
            
            var textRange = el.createTextRange(); 
            textRange.move( "character", pos ); 
            textRange.select();
            
        }
    },
    textInput = document.getElementById( 'title' );

cursorAt( textInput, 8 );