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

152
Views
¿Cómo puedo mostrar campos de entrada ocultos?

Tengo una pregunta.

Cuando tengo un formulario con, digamos, unos 100 campos de entrada ocultos, ¿cómo puedo mostrarlos uno por uno después de presionar Intro en el último campo de entrada que se muestra?

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

0

Esto agrega un controlador de clave a cada campo type="text" . El controlador de claves comprueba si el campo es el último campo type="text" y si la clave era la tecla Intro. Si es así, encuentra el siguiente campo type="hidden" , establece su tipo en "texto" y le agrega el controlador.

 function callback(e){ if ( // If it's the last text field $(this).index() == $('#demo input[type="text"]').length - 1 && // And the key pressed is Enter: e.which == 13 ) { // Find next hidden field, change it to text, and add the key handler: $(this).next('input[type="hidden"]').prop("type", "text").keypress(callback) } } // Add key handler to all text fields: $('#demo input[type="text"]').keypress(callback)
 <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script> <div id="demo"> <input type="text"> <input type="text"> <input type="text"> <input type="hidden" value="hidden1"> <input type="hidden" value="hidden2"> <input type="hidden" value="hidden3"> </div>

Referencias:

jQuery: ¿cómo verifico si un elemento es el último hermano?

¿Cómo puedo detectar presionando Enter en el teclado usando jQuery?

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!