Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
how to set cursor position on input in javascript

I have this code

input.addEventListener('input', function(e) {
   const num = Number(e.target.value)
   if ( 1 <= num && num <= 999) {
      e.target.value = num + '.000'
      const range = document.createRange()
      const sel = window.getSelection()
      range.setStart(this, e.target.value.length)
      sel.addRange(range)
   }
})

I want to when type value such as 65 input value will be 65.000, and cursor position will after number 5. In range.setStart(this, e.target.value.length) with the first parameter I don't know what textNode corresponding to input value. How can I do that? tks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda