Home > Web Front-end > JS Tutorial > body text

jQuery code example to implement the Enter key (Enter) to switch the focus of the text box_jquery

WBOY
Release: 2016-05-16 16:49:54
Original
1113 people have browsed it

The following is the implementation method:

Copy the code The code is as follows:


jQuery(function () {
jQuery('input:text:first').focus( );//Directly locate the first text box of the current page
var $inp = jQuery('input:text');//All text boxes
$inp.bind('keydown', function ( e) {
var key = e.which;
if (key == 13) {
e.preventDefault();
var nxtIdx = $inp.index(this) 1;
            jQuery(":input:text:eq(" nxtIdx ")").focus();
                                                                                                                                                                  jQuery(":input:text:eq(" nxtIdx ")").focus();
                                  

Related labels:
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