What is the difference between inputtype = "submit" and "button? -

Source: Internet
Author: User
0 reply content: Thank you for your invitation.
There are four ways to draw a button on a page:
  • This is a button. If you do not write javascript, nothing will happen.
  • After clicking this button, the user will automatically submit the form, unless you have written javascript to block it.
  • This button will also be automatically submitted in the form. The advantage of this button is that the content of the button can not only contain text, but also images and other multimedia content. (Of course, the first two pictures can also be used as the background ). Its disadvantage is that different browsers have different values; there may be other browser compatibility problems (ge Liang ).
  • Other labels, such as a, img, span, and p, then disguise them as a button using an image.
See:
[Original] AndDifference
Html-DifferenceAnd
Html-input type = "submit" Vs button tag are they interchangeable? In terms of image performance, other answers have been explained.
It must be emphasized that, in fact It is not a screen element, but a Form element. It is the same as text input and belongs to a part of "data" (characteristic is that there is a value attribute, in addition, the value of this attribute will be transmitted to the server for use.), rather than a part of the style. This design of performance and data obfuscation is the legacy of the era where early web standards are still relatively simple.
From the perspective of image performance, the two can be exactly the same through CSS.
From the perspective of screen actions, JavaScript can force both actions to be the same (both are submitted or not submitted ).
However, only the form data feature cannot be confused. You cannot regard yourself as Form data.
Therefore, if it is only a simple button that triggers some screen actions, use Otherwise, the image data will be submitted to the Server, which is generally used Of course + JS can also be replaced. Return false to onclick
Http://www.w3.org/1999/xhtml ">



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.