Forms and buttons
Given this (pseudo) html form:
<form onsubmit={() => conslole.log('submit!')}>
<input type="text" />
<button onclick={() => console.log('cancel')}>Cancel</button>
<button type="submit">Submit</button>
</form>
Quiz: If you are in the input field and press "Enter" key, what will be displayed at the console?
If you don't know, or you think is "submit", you're like me yesterday 🤷♀️
I've just learned: "submit" is the default type of a button if not specified.
How to fix it: add type="button" to the first button
- More information: MDN
<button>