Set cursor to specific position on specific line in a textarea
I’ve updated your fiddle see: http://jsfiddle.net/eghpf/2/ I’ve added var currentPosition which is used in this method function setSelectionRange(input, selectionStart, selectionEnd) { if (input.setSelectionRange) { input.focus(); input.setSelectionRange(selectionStart, selectionEnd); } else if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd(‘character’, selectionEnd); range.moveStart(‘character’, selectionStart); range.select(); } } Which comes from this jQuery Set Cursor Position in Text Area … Read more