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.