Author: | abhas9 |
---|---|
Views Total: | 68 views |
Official Page: | Go to website |
Last Update: | April 15, 2023 |
License: | MIT |
Preview:

Description:
Caret.js is a vanilla JavaScript library that allows you to set and get the caret position in the editable content.
Supports both textarea and contenteditable elements.
How to use it:
Install & Download.
# NPM $ npm install vanilla-caret-js --save
Include the minified version of the Caret.js from the dist
folder.
<script src="./dist/VanillaCaret.min.js"></script>
Initialize the library on the editable content.
<div contenteditable="true" id="example"> content here </div>
var caret = new VanillaCaret(document.getElementById('example'));
Set the caret position.
caret.setPos(3);
Get the current caret position.
caret.getPos();
Changelog:
04/15/2023
- Fix textarea bug
v1.1.0 (07/16/2022)
- Update
This looks great! Just one question – Is it compatible with all modern browsers? Any compatibility issues?