Home > Article > Web Front-end > How to use Enter instead of TAB when filling in the form_Form special effects
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: