Story Origin:
In fact, this problem has been met yesterday, but yesterday is a company's old staff to help me this intern, and I do (guess) set (test) That old staff also do not know this difference. And then today we have the same problem.
Synopsis of the story:
Now in the company to do a project, using the ANGULARJS framework, my boss gave me an interface service, to me to call and test, I deployed the project package after the local tomcat server, began to write the front-end code, From HTML to CSS to JavaScript (less) to Bootstrap, good. Now the front-end static interface comes out. Then with the boss to the interface service to test, ANGULARJS is an MVVM framework, is typically two-way binding, and then after writing the relevant logic code, each interface will not make sense to jump to their own, I see my code, if response return is true, Should jump to the order interface, and false is to jump to the login interface, in short, do not jump to yourself, it is strange! Then I opened the chrome developer tool and found that the angular function was not written every time. Later, check out Ng-model no problem, and then found that the type of input is submit, I try to change to button, ouch, altogether everything OK. This made me baffled, so I wrote this essay and found out the truth of the matter.
Story Truth:
Overall: input and button can be used when the button can be submitted to the backend for the backend processing.
Different points: ①input is input, but type= "submit" After, also play the role of submission, so input is to submit the form
<input type= "Submit" value= "Submission" >
②button is a button, he is a pure button, if not add action on the button, click No response, only add similar to type= "submit" onclick= "xxx ()" To play the role of button submission.
<button type= "Submit" > Confirm </button>
Therefore, according to the large principle of software design mode---a single responsibility principle, it is recommended to use button as buttons, and less with input as the submit button, the input button should be used as input to the data.
The above content from an intern learning front-end sentiment. Improper place, also please spectators can point out, and here thank you!
The difference between the button of input and the submit