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

171
Views
Evite eliminar el valor de entrada completo en la tecla de retroceso

Tengo un campo de entrada que borra todas las palabras que contiene cuando presiono la tecla de retroceso.

Traté de implementar un pequeño código para eliminar las palabras letra por letra pero recibo un error: selectInput.substring is not a function .

 let selectInput = document.querySelector('#searchedWord'); selectInput.addEventListener("keydown", function(e) { const key = e.key; if (key === "Backspace") { selectInput.value = selectInput.substring(0, selectInput.length -1); // other code to be exectuded below } });

¿Qué me estoy perdiendo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

"selectInput" NO es una cadena en su contexto, es un objeto DOM (o DOM-tree [=array] si se han encontrado varios elementos, pero como usó una ID "#"searchedWord, deberíamos estar bien aquí)

debe acceder al atributo ".value"

Probar:

 selectInput.value = selectInput.value.substring(0, selectInput.length -1)

Básicamente, ya lo hiciste justo donde lo asignaste. :D

about 4 years ago · Juan Pablo Isaza Report
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!