Интерфейс HTMLButtonElement предоставляет свойства и методы для управления элементами <button>
(помимо обычного интерфейса HTMLElement
, он также доступен - по наследованию) .
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 20%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 120" preserveAspectRatio="xMinYMin meet"><a xlink:href="https://developer.mozilla.org/ru/docs/Web/API/EventTarget" target="_top"><rect x="1" y="1" width="110" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="56" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">EventTarget</text></a><polyline points="111,25 121,20 121,30 111,25" stroke="#D4DDE4" fill="none"/><line x1="121" y1="25" x2="151" y2="25" stroke="#D4DDE4"/><a xlink:href="https://developer.mozilla.org/ru/docs/Web/API/Node" target="_top"><rect x="151" y="1" width="75" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="188.5" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">Node</text></a><polyline points="226,25 236,20 236,30 226,25" stroke="#D4DDE4" fill="none"/><line x1="236" y1="25" x2="266" y2="25" stroke="#D4DDE4"/><a xlink:href="https://developer.mozilla.org/ru/docs/Web/API/Element" target="_top"><rect x="266" y="1" width="75" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="303.5" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">Element</text></a><polyline points="341,25 351,20 351,30 341,25" stroke="#D4DDE4" fill="none"/><line x1="351" y1="25" x2="381" y2="25" stroke="#D4DDE4"/><a xlink:href="https://developer.mozilla.org/ru/docs/Web/API/HTMLElement" target="_top"><rect x="381" y="1" width="110" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="436" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTMLElement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#D4DDE4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#D4DDE4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#D4DDE4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#D4DDE4"/><a xlink:href="https://developer.mozilla.org/ru/docs/Web/API/HTMLButtonElement" target="_top"><rect x="321" y="65" width="170" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="406" y="94" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTMLButtonElement</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
Свойства
Наследует свойства от его родителя, HTMLElement
.
Имя | Тип | Описание |
---|---|---|
accessKey |
DOMString |
Определенная кнопка клавиатуры, дающая доступ к кнопке. |
autofocus |
Boolean |
Управление должно получить фокус ввода при загрузки страницы, пока пользователь не отменяет его, например, набирая на клавиатуре в другом контроле. Только один формо-ассоциированный элемент в документе может иметь указанный атрибут. |
disabled |
Boolean |
Контроль выключен, что означает, он не принимает любых кликов. |
form Только для чтения |
HTMLFormElement |
Форма этой кнопки связана с ней. Если кнопка потомок элемента формы, то этот атрибут ID этого элемента формы. Если форма не связана с формой элемента, то атрибут может быть ID любой формы элемента в том же документе , или значение null если нет совпадений. |
formAction |
DOMString |
URI ресурса, обрабатывающего информацию, отправленную кнопкой. Если задан, то переопределяет |
formEncType |
DOMString |
Тип содержимого, используемый для отправки формы на серевер. Если указан этот атрибут, то он переопределяет enctype атрибут элемента <form> , который является владельцем этого элемента. |
formMethod |
DOMString |
HTTP метод, который браузер использует для отправки формы. Если задан, тогда он переопределяет |
formNoValidate |
Boolean |
Показывает что форма не будет проверена при отправке. Если задано, тогда переопределяет |
formTarget |
DOMString |
Имя или ключевое слово, указывающее, где должен отображаться ответ, полученный после отправки формы. Если задано, тогда переопределяет |
labels Только для чтения |
NodeList |
Список элементов <label> , которые являются метками для этой кнопки. |
menu |
HTMLMenuElement |
Элемент меню, который будет отображаться, если кнопка нажата и имеет тип type="menu" . |
name |
DOMString |
Имя объекта отправляемое с формой. HTML5Если задано, не должно быть пустой строкой. |
tabIndex |
long |
Номер, представляющий последовательность перехода между полями при нажатии на Tab |
type |
DOMString |
Указывает поведение кнопки. Это перечисляемый атрибут со следующими возможными значениями:
|
validationMessage Только для чтения |
DOMString |
A localized message that describes the validation constraints that the control does not satisfy (if any). This attribute is the empty string if the control is not a candidate for constraint validation ( |
validity Только для чтения |
ValidityState |
The validity states that this button is in. |
value |
DOMString |
The current form control value of the button. |
willValidate |
Boolean |
Indicates whether the button is a candidate for constraint validation. It is false if any conditions bar it from constraint validation. |
Methods
Наследует свойства от его родителя, HTMLElement
.
Name | Return Type | Description |
---|---|---|
checkValidity() |
Boolean |
Not supported for button elements. |
setCustomValidity(in DOMString error) |
void |
Not supported for button elements. |
WIth Gecko-based browser, use the :-moz-submit-invalid
pseudo-class to style submit buttons based on the validation of a form.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard Определение 'HTMLAnchorElement' в этой спецификации. |
Живой стандарт | The following attribute has been added: menu .The type attribute can take one more value, "menu" . |
HTML5 Определение 'HTMLAnchorElement' в этой спецификации. |
Рекомендация | The attributes tabindex and accesskey , are now defined on HTMLElement .The following attributes have been added: autofocus , formAction , formEncType , formMethod , formNoValidate , formTarget , labels , validity , validationMessage , and willValidate .The following methods have been added: checkValidity() , setCustomValidity() .The type attribute is no more read-only. |
Document Object Model (DOM) Level 2 HTML Specification Определение 'HTMLAnchorElement' в этой спецификации. |
Устаревшая | No change from Document Object Model (DOM) Level 1 Specification. |
Document Object Model (DOM) Level 1 Specification Определение 'HTMLAnchorElement' в этой спецификации. |
Устаревшая | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Да) | 1.0 (1.7 или ранее) | (Да) | (Да) | (Да) |
Form-related attributes | (Да) | 4.0 (2.0) | (Да) | (Да) | (Да) |
labels |
(Да) | Нет Не реализовано (смотрите баг 556743) | ? | ? | ? |
menu & type="menu" |
Нет | Нет | Нет | Нет | Нет |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Да) | 1.0 (1.0) | (Да) | (Да) | (Да) |
Form-related attributes | (Да) | 4.0 (2.0) | (Да) | (Да) | (Да) |
labels |
(Да) | НетНе реализовано (смотрите баг 556743) | ? | ? | ? |
menu & type="menu" |
Нет | Нет | Нет | Нет | Нет |
See also
- HTML element implementing this interface:
<button>