An open API service indexing awesome lists of open source software.

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.

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).