The difference between the button of input and the submit

Source: Internet
Author: User
Tags chrome developer

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.