D
D
Denis Bukreev2016-09-01 18:07:04
JavaScript
Denis Bukreev, 2016-09-01 18:07:04

How to get caret position in textarea?

The task arose: when you click on the button (and there are almost 3 dozen of them), text should be inserted into the textarea where the caret is located.
But I don’t know which way to look in order to understand how to solve the problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DTX, 2016-09-01
@DirecTwiX

let sel = window.getSelection();
let range = sel.getRangeAt(0);
let boundary = range.getBoundingClientRect();

https://developer.mozilla.org/ru/docs/Web/API/wind...

D
Denis Ineshin, 2016-09-01
@IonDen

stackoverflow.com/questions/4928586/get-caret-posi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question