Home  >  Article  >  Web Front-end  >  How to use Enter instead of TAB when filling in the form_Form special effects

How to use Enter instead of TAB when filling in the form_Form special effects

WBOY
WBOYOriginal
2016-05-16 19:08:351135browse

The key point is tabindex. The design idea is: set a tabindex for each form element, and its value is the value of the tabindex of the previous form element plus one. The function of the function is to first add the current tabindex when the user presses the Enter key. The value of tabindex is increased by one, and then compared with the tabindex value of each form element one by one. If they are equal, the focus is moved to the form element.

First, we need to set an onkeyup event in the form body:



Secondly, set a tabindex value in each form element, assuming that the form There are three elements, then we set the tabindex value as follows:


Statement:
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