Jquery press enter to replace the implementation of the tab key

Source: Internet
Author: User
$ (Function () {$ ("form [name = 'articleform'] input: Text "). keypress (function (e) {If (E. which = 13) // determines whether to press the Enter key {var inputs = $ ("form [name = 'articleform']"). find (": Text"); // obtain all input boxes in the form. var idx = inputs. index (this); // obtain the position of the current focus input box if (idx = inputs. length-1) // determine if it is the last input box {If (confirm ("the last input box has been input, submit? ") // User confirmation {
$ ("Form [name = 'articleform']"). submit (); // submit the form} else {inputs [idx + 1]. focus (); // set the focus inputs [idx + 1]. select (); // selected text} return false; // cancel default submission behavior }});});


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.