How do I make a div with a contentEditable set show a blinking cursor on the page load?

I would just like to have an editable div that acts like a text box that focuses on page loading (i.e. a blinking cursor is visible, and text input is displayed in a div without having to select a div with the mouse). I tried calling focus () on an editable div, but this does not work.

+3
source share
1 answer

I'm not sure you can control the cursor, but you can just focus the element:

function initPage() {
    var elEd = document.getElementById('editor');
    elEd.contentEditable=true;
    elEd.focus();
}

Chrome, ID - , . Firefox , , . .

+7

Source: https://habr.com/ru/post/1745589/


All Articles