8
I have a simple question facing the semantic part. The button I can modify your actions using the Javascript. When I should wear it or trade it for submit ?
<input type="button"> e <input type="submit">
8
I have a simple question facing the semantic part. The button I can modify your actions using the Javascript. When I should wear it or trade it for submit ?
<input type="button"> e <input type="submit">
11
<button type="submit" and <button type="button"The difference is that type="submit" does the Submit of a form into which that button is inserted; while the type="button" has no default action.
Javascript can intercept the event submit in case, for example, you want to validate the data entered in the form. The type="button" does no more than be a button and trigger any code that Javascript may have for it.
<input type="submit" and <button type="submit"They are similar but different. Semantics must be the factor of choice:
User input: use input
Click on a button: use button
"In the old days" when browsers were less predictable and acted more unpredictably (I’m talking mostly about IE) input type="submit" was the safest.
The great advantage of button is that it can have HTML inside while the input is auto-closed and the text it shows is defined in the attribute value.
Don’t forget that button without type="button", or is without defined type acts as a type="submit", is its functionality "by default".
I loved the "by default".
And the <button>, when should I use it?
@Haxz If you want to put HTML in, like a svg or Giff from a Loading for example... Or if you are developing thinking of Firefox < 30 and have problems with the line-height in the <input>.
@Sergio, "is auto-closed and the text he shows is set in the value attribute." In fact by recommendation it should be used as follows: <button type="submit">Save changes</button>
Read wrong, oops! :)
Nowadays the thing goes beyond the logistics of the element. Do what is done with <button> using a <input> it’s a lot more work.
Browser other questions tagged html
You are not signed in. Login or sign up in order to post.
I don’t know if it’s exactly duplicated, but see if this question helps input type="Submit" or button type="Submit"
– abfurlan
I do not see it as a duplicate, but the question is also unclear because it lacks context. Context that could perhaps classify the question as duplicate.
– Bruno Augusto