When I replace the whole content of an editable div by jquery, how can I prevent the cursor from moving to the start after any key press?
$('.editme').on('change keyup', function(e){
wordFilter($(this).text());
$(this).text(wordFilter($(this).text()));
});
I tried to save and restore the cursor position with selectionStart and selectionEnd, but it doesnt work on the editable div. Is there any simple way in jquery?
UPDATE:
WORKING SOLUTION: (with included caret plugin)
$('.editme').on('change keyup', function(e){
var caretPos = $(this).caret();
wordFilter($(this).text());
$(this).text(wordFilter($(this).text()));
$(this).caret(caretPos);
});