I just noticed this and am curious. I have two <span>
s with onClick events that do basically the same thing; one had type='button'
, but the other did not. They were both behaving exactly the same.
Is there any point to adding
type='button'
to an element other than making it more clear what it is?
Even a standard button
element seems to behave exactly the same with and without.
<button onclick="alert('Hello world!')">Click Me!</button>
&&
<button type="button" onclick="alert('Hello world!')">Click Me!</button>