Set cursor position on contentEditable
This solution works in all major browsers: saveSelection() is attached to the onmouseup and onkeyup events of the div and saves the selection to the variable savedRange. restoreSelection() is attached to the onfocus event of the div and reselects the selection saved in savedRange. This works perfectly unless you want the selection to be restored … Read more