Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

216
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda