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

148
Views
range.deleteContents() está eliminando inesperadamente espacios en blanco antes del rango en sí

si el texto es sure :f , range.deleteContents() suponga que debe eliminar :f , pero está eliminando :f . Parece espacio antes : el personaje también se está eliminando.
Cómo conservar el espacio antes : ? Alternativamente, ¿hay alguna otra forma de eliminar texto que sea más confiable?

 const selection = window.getSelection(); const range = document.createRange(); range.setStart(selection.focusNode, 5); // start of : range.setEnd(selection.focusNode, 7); range.deleteContents(); //deletes ` :f`

No importa si configuro range.setStart(selection.focusNode, 4) o range.setStart(selection.focusNode, 5) ... se elimina el espacio.

Aquí está el violín para jugar: https://jsfiddle.net/JerryGoyal/o2c9f5gw/

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!