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

175
Views
el método de enfoque en el cuadro de texto en realidad no establece el enfoque

Tengo un comportamiento extraño aquí con el método de enfoque. Solo quiero entender por qué está sucediendo así.

Caso 1: con el siguiente código cuando salgo del último elemento, es decir, el hipervínculo driveD, el enfoque no se establece en el primer cuadro de texto aunque apliqué .focus() al primer cuadro de texto.

 function lastFocusOut() { alert('focus out ,setting focus to first text box'); document.getElementById('nameId').focus(); }
 input,a,button{ display:block; margin:10px; }
 <form> <input id="nameId" type="text" name="name"> <a href="c:\">drive</a> <input id="nameId1" type="text" name="name"> <input type="submit" value="test" /> <input type="text" name="name"> <a href="d:\">driveE</a> </form> <a href="d:\" onblur="lastFocusOut()">driveD</a> </body>

Caso 2: cuando agrego un botón después del último hipervínculo, vuelve a poner el foco en el primer cuadro de texto.

 function lastFocusOut() { alert('focus out ,setting focus to first text box'); document.getElementById('nameId').focus(); }
 input,a,button{ display:block; margin:10px; }
 <form> <input id="nameId" type="text" name="name"> <a href="c:\">drive</a> <input id="nameId1" type="text" name="name"> <input type="submit" value="test" /> <input type="text" name="name"> <a href="d:\">driveE</a> </form> <a href="d:\" onblur="lastFocusOut()">driveD</a> </body> <button type ="submit" >Submit</button>

Quiero entender dos cosas aquí.

1) Por qué el enfoque no se establece en el primer cuadro de texto en el caso 1.

2) Lo que realmente hace la diferencia es solo agregar el botón al final, lo que hace que el código funcione como se esperaba.

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!