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

115
Views
valor de entrada en keyup (codepen)

Tengo un problema con este codepen https://codepen.io/Kimple/pen/MWEBGZy?editors=0011

En la función titleCheck() , quiero obtener el valor de <input type="text" id="title" placeholder="title"> Pero siempre obtengo un valor vacío y no sé por qué.

Probé el mismo código en JSFIDDLE y tuve el mismo problema.

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

0

Guardó el valor en la variable cuando se inicializó, por lo tanto, cuando la entrada está vacía. El valor no se actualiza automáticamente. Debe solicitarlo con cada pulsación de tecla. De esta manera debería registrar el valor correcto:

 function titleCheck() { title.addEventListener('keyup', (event) => { console.log(title.value) // ask for the value every time to see it updating titleValue = title.value if (titleValue != '') { checkBox.checked = true; checkboxCheck(); } else { checkBox.checked = false; checkboxCheck(); } }) } titleCheck()

Además, la próxima vez intente usar fragmentos en su respuesta en lugar de un enlace a codepen u otro editor externo.

about 4 years ago · Juan Pablo Isaza Report

0

Debe reasignar titleValue, porque lo configuró para que esté vacío al principio y no lo cambie después.

 function titleCheck() { title.addEventListener('keyup', (event) => { titleValue = document.getElementById("title").value console.log(titleValue) if (titleValue != '') { checkBox.checked = true; checkboxCheck(); } else { checkBox.checked = false; checkboxCheck(); } }) }
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!