Skip to content

Instantly share code, notes, and snippets.

@roundrop
Created September 10, 2013 02:57
Show Gist options
  • Save roundrop/6504455 to your computer and use it in GitHub Desktop.
Save roundrop/6504455 to your computer and use it in GitHub Desktop.
javascriptでテキストボックスの末尾にキャレット移動
<html>
<head></head>
<body>
<input type="text" id="foo" value="" />
</body>
</html>
var t = document.getElementById('foo');
t.value = '12345678901234567890123456789012345678901234567890';
var len = t.value.length;
t.focus();
t.setSelectionRange(len, len);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment