Move Cursor to End of Input | JavaScript

PHOTO EMBED

Sat May 16 2020 06:23:00 GMT+0000 (Coordinated Universal Time)

Saved by @RedQueen #javascript

function moveCursorToEnd(el) {
    if (typeof el.selectionStart == "number") {
        el.selectionStart = el.selectionEnd = el.value.length;
    } else if (typeof el.createTextRange != "undefined") {
        el.focus();
        var range = el.createTextRange();
        range.collapse(false);
        range.select();
    }
}
content_copyCOPY

https://css-tricks.com/snippets/javascript/move-cursor-to-end-of-input/