0

Input submit Vs Button submit tags? 🤷🏼‍♀️

Usually when I see some php tutorials or github repositories they use the input tag with the "submit" type instead a button. Why they use it? Which one is better? And why? (When I change the input tag for a button I get the same result so that's where my doubt has borned)

11th Apr 2021, 6:20 PM
Ariadne Rangel
Ariadne Rangel - avatar
3 odpowiedzi
+ 1
<input type="button" /> buttons will not submit a form - they don't do anything by default. They're generally used in conjunction with JavaScript as part of an AJAX application. <input type="submit"> buttons will submit the form they are in when the user clicks on them, unless you specify otherwise with JavaScript.
11th Apr 2021, 8:45 PM
Jamal Saied
Jamal Saied - avatar
0
Jamal I'm sorry, maybe I didn't explain it well. I mean the difference between <button type="submit"> and <input type="submit"> 💁🏼‍♀️
11th Apr 2021, 9:02 PM
Ariadne Rangel
Ariadne Rangel - avatar
0
<button> allows content within, <input> does not. <button> by default acts as submitter when placed within a <form>. Adding attribute `type = "button"` changes the default behaviour.
12th Apr 2021, 3:59 AM
Ipang