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