Submit is a Button specially used to submit forms. There are two main differences between them:
type=button is simply a button function
type=submit is to send the form
(1) Submit submits the form (()) as the default event after its onclick, but not Button
(2) When submitting the form, all html input elements with name attribute (including input tags, button tags, select tags, etc.) will be submitted as key-value pairs, except for Submit objects. Submit objects are submitted as key-value pairs only in the submission after they are clicked.
But for those working in WEB UI, you should note that using submit to improve the ease of use of pages:
After using submit, the page supports keyboard enter key operation, and many WEB software designers may not notice the uniformity of submit.
After using button, the page often does not support the enter key. Therefore, it is necessary to support the enter key, and a submit must be set. The default enter key operates on the first submit on the page.
After executing onClick, go to action. Can be automatically submitted without onClick. So you can say that onclick here.
After executing onClick, the jump file is controlled in the js file. OnClick is required for submission.
for example:
1,onclick="='';();"
This implements the submit function.
To put it bluntly, submit will have a jump and the page will be refreshed; but button will not be refreshed, it will be a button; it can be used<button type="submit/button/reset"></button>
To generate buttons, more flexible and more control over styles.
The above is the difference between type="button" and type="submit" in JS introduced to you by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!