get the caret's position: pos = $(textarea).caret() set the caret's position: $(textarea).caret(pos)
pos = $(textarea).caret()
$(textarea).caret(pos)