S
S
saalaus2018-08-16 21:48:51
JavaScript
saalaus, 2018-08-16 21:48:51

How can I make one object be created on the textarea next to the caret?

In general, I want to know how to know the location of the caret in a textarea and then create another div object on top of it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-08-16
@saalaus

Replace textarea with div contenteditable=true
Get cursor position by selection.getRange
Insert span with zero-width space into this position
Get span coordinates
Sorry, no links, I'm writing from my phone. But each of these things is easy to google.
(there is a glitch, the spaces disappear somewhere, but I'm too lazy to figure it out)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question