Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Get and set the user's caret/selection on input/textarea elements
JavaScript
Branch: master
Failed to load latest commit information.
.gitmodules
LICENSE
README.md
caret-position.js
package.json
test.html
test.js

README.md

caret-position

Get and set the user's text selection on an input or text area.

See test.html for example usage.

API

// Set caret position after the first character
caretPosition.set(input, 1)
caretPosition.get(input) // -> { start:1, end:1, caret:1 }

// Set text selection to the second and third character
caretPosition.set(input, 1, 3)
caretPosition.get(input) // -> { start:1, end:3, caret:3 }
Something went wrong with that request. Please try again.