Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
How to get cursor position in contenteditable div including HTML tags?

I'm writing a program where I need the position of the cursor in an editable div, and tags should be counted as well.

Example:

<div contenteditable="true">
<p>Text here!</p>
</div>

If the cursor is placed after "Text", the cursor position should be 7, not 4. This happens when the HTML tag is included.

Solutions like this one: https://stackoverflow.com/a/53128599/12834165, only count the visible characters, resulting in the output being 4.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!