Introduction to the difference between button and submit
零下一度
Release: 2017-07-19 13:20:18
Original
4670 people have browsed it
There are four ways to draw a button on a page:
This is a button. If you don't write javascript, nothing will happen when you press it.
Such a button will automatically submit the form after the user clicks it, unless you write javascript to prevent it.
Other tags, such as a, img, span, div, and then use a picture to disguise it as a button.
Submit is a Button specially used to submit forms. There are two main differences from Button: type=button is simply a button function type=submit is to send a form (1) Submit uses form submission (form.submit()) as its default event after onclick, but this is not the case for Button (2) When the form is submitted, all html input elements with the name attribute (including input tags, button tags, select tags, etc.) will be submitted as key-value pairs, except for the Submit object. The Submit object will only be submitted as a key-value pair in the submission after it is clicked. But those who are engaged in WEB UI should note that using submit to improve the usability of the page:
After using submit, the page supports keyboard enter key operation, but many WEB software designers may not Notice that submit is unified.
After using the button, the page often does not support the enter key. Therefore, if you need to support the enter key, you must set up a submit. By default, the enter key operates on the first submit on the page.
After executing onClick, go to action. Can be submitted automatically without onClick. So onclick is not required here.
After executing onClick, the jump file is controlled in the js file. Submit requires onClick. For example: 1. onclick="form1.action='a.jsp';form1.submit();" This realizes the submit function.
To put it more plainly, submit will have a jump and the page will refresh; but button will not refresh, it is just a button; you can use
The above is the detailed content of Introduction to the difference between button and submit. For more information, please follow other related articles on the PHP Chinese 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