https://github.com/cobyism/jquery-caret
Set and query caret position within textareas and text inputs.
https://github.com/cobyism/jquery-caret
Last synced: about 1 year ago
JSON representation
Set and query caret position within textareas and text inputs.
- Host: GitHub
- URL: https://github.com/cobyism/jquery-caret
- Owner: cobyism
- License: mit
- Created: 2013-01-09T08:14:38.000Z (over 13 years ago)
- Default Branch: gh-pages
- Last Pushed: 2013-07-01T15:52:28.000Z (almost 13 years ago)
- Last Synced: 2025-04-19T16:39:52.048Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://cobyism.com/jquery-caret
- Size: 143 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Caret
=====
A small jQuery plugin to set and query caret (keyboard input cursor) position within ``s and text ``s.
## Usage
Include scripts for jQuery and this plugin in your HTML (refer to [the demo](http://cobyism.com/jquery-caret) for an example):
```html
```
Then use the `caret()` method to set or query the caret position for your ``.
```js
$('.your-textarea').caret(5)
//=> Caret is placed after the 5 character in the text field
$('.your-textarea').caret()
//=> 5
```
Note: that the caret position index starts at `0`, not `1`.
## Browser support
This should function correctly in most modern browsers:
- Recent versions of Chrome, Safari, Firefox, Opera.
- Internet Explorer 9 (earlier versions untested).
## Contributions
Contributions welcome! :grinning:
## License
See [LICENSE](https://github.com/cobyism/jquery-caret/blob/gh-pages/LICENSE).