This is the caret positioning code that I created to use in my Masked Input plugin for jQuery. This plugin will let you manipulate or query the caret position of text inputs and textareas.
.caret()
- gets the current caret position for the first element in the set of matched elements..caret(begin,end)
- sets the caret position on the set of matched elements..caret(begin)
- sets the caret position on the set of matched elements. This is the same same calling .caret with the same begin and end value.