Difference between input element and button element of submit type in HTML

2

What is the difference between these two elements when using them to trigger an event? Is there something that the other party can not do? (apart from not being able to use the element input outside of an element form )

    
asked by dwarandae 30.01.2016 в 05:23
source

2 answers

4

Look with both of you, you can trigger events, usually the <input type="submit"> is used to send forms and applications of those types, but you can also give different clear usage, while the <button type=""> tag is used in one more application aspect and trigger events or actions managed by java script or other language example of the <button> tag is that you want to change the color of a certain element when clicking And on the other hand it is not that you can not use <input type="submit"> , what happens is that usually applies the actions when this is within a <form> but you can change the behavior of this through JavaScript events

    
answered by 30.01.2016 / 05:54
source
4

As far as events are concerned, <button type="submit"> e <input type="submit"> are equivalent.

The only difference (and not between the two tags) in terms of events would be the behavior of <button type="submit"> in old browsers, in which it could send different values: in some cases (IE6) it would be the text contained between the tags , and in other cases it would be the value specified in value .

Apart from that, the main (only?) difference between <button type="submit"> e <input type="submit"> is the type of content that can be presented with each of them. The first one can contain HTML elements (eg: text + images) while the second one can only contain text:

<input type="submit" value="Pulsar <img src='http://lorempixel.com/20/20/' />">
<hr/>
<button type="submit">Pulsar <img src='http://lorempixel.com/20/20/' /></button>
    
answered by 30.01.2016 в 20:29