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