There is no such thing as a stupid question, so here we go: What is the difference between <input type='button' />
and <input type='submit' />
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
A 'button' is just that, a button, to which you can add additional functionality using Javascript. A 'submit' input type has the default functionality of submitting the form it's placed in (though, of course, you can still add additional functionality using Javascript).
<input type="button" />
buttons will not submit a form - they don't do anything by default. They're generally used in conjunction with JavaScript as part of an AJAX application.<input type="submit">
buttons will submit the form they are in when the user clicks on them, unless you specify otherwise with JavaScript.W3C make it clear, on the specification about Button element
Button may be seen as a generic class for all kind of Buttons with no default behavior.
W3C
<input type="button">
can be used anywhere, not just within form and they do not submit form if they are in one. Much better suited withJavascript
.<input type="submit">
should be used in forms only and they will send a request (either GET or POST) to specified URL. They should not be put in any HTML place.IE 8 actually uses the first button it encounters submit or button. Instead of easily indicating which is desired by making it a input type=submit the order on the page is actually significant.
Button won't submit form on its own.It is a simple button which is used to perform some operation by using javascript whereas Submit is a kind of button which by default submit the form whenever user clicks on submit button.