Javascript - Position Caret
How can we position the caret?
var el = cmp.el.dom;
if (el.createTextRange) {
var range = el.createTextRange();
var pos = el.value.length;
range.moveStart("character", pos);
range.select();
} else if (el.setSelectionRange) {
el.setSelectionRange(el.value.length,0)
}The above code works for IE11 (with compatibility view setting on). I used the above code position the caret at the end of an input field. See https://forum.sencha.com/forum/showthread.php?95486-Cursor-Position-in-TextField
page revision: 2, last edited: 22 Nov 2021 23:24





