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

76
Views
Crear un rango en un punto específico

Traté de crear un rango, que lleva a un punto específico en el texto, pero esto fue muy difícil con los ChildNodes, porque no se puede llegar exactamente a un punto en el texto, sino sólo por ejemplo, el principio o el final de un ChildNode .
¿Existe una manera de llegar al punto entre "te" y "st" (como poner el cursor entre "te | st") o es posible crear un rango independiente de los childnodes?

Aquí está mi código:

 function myFunction(el) { var textNode = el.childNodes[1]; var range = document.createRange(); range.selectNodeContents(el); range.setStart(textNode, 0); range.setEnd(textNode, 0); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range); }
 <!DOCTYPE html> <html> <body> <div id="myText" contenteditable>test<br>test</div> <button type="button" onclick='myFunction(document.getElementById("myText"))'>Go into Text</button> </body> </html>

¡Gracias por cada ayuda!

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!