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

215
Views
How to replace the selected text dynamically using input element In React

Need of the following feature

  1. select the text/string using the mouse (just like we usually use on mouseDown and mouseUp )
  2. Replace the selected string with the input tag
  3. replace the original string with the text which we filled in the input tag.

Below images shows whole idea.

step 1: select the text (select only one not same as shown in image

step 2: replace selected text with input tag

step 3 : enter text in input tag

step 4: on button click we add that string to original string and input element will remove now

I tried replacing selected text with different text but was unable to replace it dynamically !!

posts i read before post this question

  • How to find index of selected text in getSelection() using javascript?
  • How to get the start and end points of selection in text area?
  • replace selected text in contenteditable div
  • Replacing selected text - HTML / JavaScript
  • Select Text & highlight selection or get selection value (React)
about 4 years ago · Juan Pablo Isaza
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!