set focus position contenteditable javascript code example
Example: how to control where the text cursor on div
function setCaret(row, col) {
var el = document.getElementById("editable")
var range = document.createRange()
var sel = window.getSelection()
range.setStart(el.childNodes[row - 1], col)
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
}