Set And Get Caret Position Using jQuery - Caret.js

File Size: 4.36 KB
Views Total: 3647
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Set And Get Caret Position Using jQuery - Caret.js

Caret.js is a tiny jQuery plugin created to set and get caret (text cursor) position in textarea, input, or contenteditable element.

See Also:

How to use it:

1. Load the Caret.js script right before the </body> tag but after jQuery library.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/jquery.caret.js"></script>

2. Get the caret position.

<!-- Textarea -->
<textarea id="example">
  ... Any Content Here ...

<!-- Or Input Field -->
<input id="example" />

<!-- Or contenteditable -->
<div id="example" contenteditable="true">
  ... Any Content Here ...

3. Set the caret position.


This awesome jQuery plugin is developed by accursoft. For more Advanced Usages, please check the demo page or visit the official website.