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

174
Views
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
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!