Last active
April 9, 2017 00:51
-
-
Save Marlysson/ca2e33e9da7f2ac2922e77f74fb257e7 to your computer and use it in GitHub Desktop.
Focar próximo elemento do html ao pressionar ENTER em um input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input type="" name="" placeholder="Input 1"> | |
| <input type="" name="" placeholder="Input 2"> | |
| <input type="" name="" placeholder="Input 3"> | |
| <button>Botão 3</button> | |
| <script type="text/javascript"> | |
| let botoes = document.querySelectorAll("input"); | |
| botoes.forEach(function(elemento,indice){ | |
| elemento.addEventListener("keydown",function(evento){ | |
| if (evento.keyCode == 13){ | |
| proximo = this.nextElementSibling; | |
| proximo.focus(); | |
| } | |
| }); | |
| }) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment