Home > Web Front-end > HTML Tutorial > How to achieve focus jump in textbox by pressing Enter key? _html/css_WEB-ITnose

How to achieve focus jump in textbox by pressing Enter key? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:43
Original
1203 people have browsed it

Question:
When I press the Enter key in the username textbox, how can the focus jump to the password textbox?


Reply to discussion (solution)










Username:
Password:




<script> <br> var usernameObj = document.getElementById("username"); <br> usernameObj.onkeydown = function(event) { <br> e = event ? event :(window.event ? window.event : null); <br> // Press Enter key and the input box value is not empty <br> if(e.keyCode==13 && usernameObj.value){ <br> document.getElementById("password").focus(); <br> } <br> } <br> </script>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template