4
4
4eloBek2015-08-25 22:15:35
JavaScript
4eloBek, 2015-08-25 22:15:35

How to move caret in div one line below?

There is a field . How to programmatically move the caret to the next line (to the beginning)? I could only move in the first line, and then ... alas ( Here is an example (jsfiddle.net) Tell me how to do this? <div contenteditable="true"></div>



Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2015-08-26
@4eloBek

Like this: jsfiddle.net/97dw6382/2
In short, the range should be the element's DOM number, not the text offset.
Those. when there is text, then this is a text offset, but if any dom element is encountered, then its number must be indicated.
There is a more detailed description here: stackoverflow.com/a/6939886

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question