Answers for "how to control where the text cursor on div"

0

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)
}
Posted by: Guest on February-10-2021

Code answers related to "how to control where the text cursor on div"

Code answers related to "Javascript"

Browse Popular Code Answers by Language