HTML
html/button-type
Every button states its type (button, submit or reset); the default is submit.
drobnastatycznefe-html
Dlaczego
A <button> with no type submits its form. A "Show password" or "Add row" button inside a form then sends the form by accident, and the bug appears only when the markup is moved into a form later.
Poprawka
Write type="button" on every button that runs script, and type="submit" on the one that submits, so intent is visible in the markup.
Przykłady
<!-- bad -->
<button onclick="toggle()">Show password</button>
<!-- good -->
<button type="button" onclick="toggle()">Show password</button>Źródła
Fakty
- Identyfikator
html/button-type- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- Uczy jej skill
fe-htmlHTML documents and semantics- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain html/button-type