Кнопки активно используются в страничках, веб приложениях. Вот пара нюансов:
- Кнопки за пределами формы по умолчанию ничего не делают. Нужно делать обработку кликов с помощью javascript.
- Кнопки в пределах формы имеют один из трех типов:
- submit - отправка формы
- reset - очистка формы
- button - ничего не делает по умолчанию
- Тип задается через атрибут type. Если не задать или задать неправильное значение - тип будет submit.
type
submit
: The button submits the form data to the server. This is the default if the attribute is not specified for buttons associated with a<form>
, or if the attribute is an empty or invalid value.reset
: The button resets all the controls to their initial values, like <input type="reset">. (This behavior tends to annoy users.)button
: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
Внутри формы, следующие варианты будут работать одинаково:
<button type="submit">OK</button>
<button>OK</button>
No comments:
Post a Comment