Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created November 17, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonleighton/3d820c3b69516fef9ec0a76bd69c9ae6 to your computer and use it in GitHub Desktop.
Save jonleighton/3d820c3b69516fef9ec0a76bd69c9ae6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>initial selection test</title>
</head>
<body id="home">
<form>
<input type="text" value="test">
<textarea>test</textarea>
</form>
<script type="text/javascript">
window.onload = function() {
console.log("input selectionStart:", document.querySelector("input").selectionStart)
console.log("input selectionEnd:", document.querySelector("input").selectionEnd)
console.log("textarea selectionStart:", document.querySelector("textarea").selectionStart)
console.log("textarea selectionEnd:", document.querySelector("textarea").selectionEnd)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment