Javascript Code Get/Set Caret Position

Javascript Code Get/Set Caret Position - [1] To GET the current caret position in an input element/textarea ... [2] To SET the current caret position in an input element/textarea ...

Home Short:

To GET the current caret position in an input element/textarea:

To SET the current caret position in an input element/textarea:

Example of how to get AND set the caret position in a useful manner:

Usually you would use this in the context of an event of the input element such as a keypress, input etc.

S
H
A
R
E