<!DOCTYPE HTML><html>
<body>
<textarea>ab</textarea>
<script>
var t = document.querySelector("textarea");
t.focus();
t.selectionStart = t.selectionEnd = t.value.length;
</script>
</body>
</html>