Интерфейс HTMLElement
представляет собой любой элемент HTML. Некоторые элементы напрямую используют этот интерфейс, другие - через промежуточный интерфейс.
Свойства
Наследует свойства родителя, Element
, и реализует их через GlobalEventHandlers
и TouchEventHandlers
.
HTMLElement.accessKey
-- ключ доступа- Эта строковая переменная
DOMString
отображает ключ доступа, сопоставленный элементуElement
. HTMLElement.accessKeyLabel
Только для чтения- Возвращает
DOMString
, содержащий назначенный ключ доступа элемента. HTMLElement.contentEditable
- Является
DOMString
, где значение" true "означает, что элемент доступен для редактирования, а значение" false " означает, что это не так. HTMLElement.isContentEditable
Только для чтения- Возвращает
Boolean
, который указывает, можно ли редактировать содержимое элемента. HTMLElement.contextMenu
- Является
HTMLMenuElement
, представляющим контекстное меню, связанное с элементом. Может быть null HTMLElement.dataset
Только для чтения -- набор данных- Возвращает
domstringmap
, который позволяет получить доступ к чтению и записи атрибутов пользовательских данных элемента (data-*) . HTMLElement.dir
- Is a
DOMString
, reflecting thedir
global attribute, representing the directionality of the element. Possible values are"ltr"
,"rtl"
, and"auto"
. HTMLElement.draggable
- Is a
Boolean
indicating if the element can be dragged. HTMLElement.dropzone
Только для чтения- Returns a
DOMSettableTokenList
reflecting thedropzone
global attribute and describing the behavior of the element regarding a drop operation. HTMLElement.hidden
- Is a
Boolean
indicating if the element is hidden or not. HTMLElement.itemScope
- Is a
Boolean
… HTMLElement.itemType
Только для чтения- Returns a
DOMSettableTokenList
… HTMLElement.itemId
- Is a
DOMString
… HTMLElement.itemRef
Только для чтения- Returns a
DOMSettableTokenList
… HTMLElement.itemProp
Только для чтения- Returns a
DOMSettableTokenList
… HTMLElement.itemValue
- Returns an
Object
… HTMLElement.lang
- Is a
DOMString
representing the language of an element's attributes, text, and element contents. HTMLElement.offsetHeight
Только для чтения- Returns a
double
containing the height of an element, relative to the layout. HTMLElement.offsetLeft
Только для чтения- Returns a
double
, the distance from this element's left border to itsoffsetParent
's left border. HTMLElement.offsetParent
Только для чтения- Returns an
Element
that is the element from which all offset calculations are currently computed. HTMLElement.offsetTop
Только для чтения- Returns a
double
, the distance from this element's top border to itsoffsetParent
's top border. HTMLElement.offsetWidth
Только для чтения- Returns a
double
containing the width of an element, relative to the layout. HTMLElement.properties
Только для чтения- Returns an
HTMLPropertiesCollection
… HTMLElement.spellcheck
- Is a
Boolean
that controls spell-checking. It is present on all HTML elements, though it hasn't an effect on all of them. HTMLElement.style
- Is
CSSStyleDeclaration
, an object representing the declarations of an element's style attributes. HTMLElement.tabIndex
- Is a
long
representing the position of the element in the tabbing order. HTMLElement.title
- Is a
DOMString
containing the text that appears in a popup box when mouse is over the element. HTMLElement.translate
- Is a
Boolean
Event handlers
Most events properties, of the form onXYZ
, are defined on the GlobalEventHandlers
or TouchEventHandlers
, implemented by HTMLElement
. A few more are specific to HTMLElement
.
HTMLElement.oncopy
- Returns the event handling code for the
copy
event (баг 280959). HTMLElement.oncut
- Returns the event handling code for the
cut
event (баг 280959). HTMLElement.onpaste
- Returns the event handling code for the
paste
event (баг 280959). TouchEventHandlers.ontouchstart
- Returns the event handling code for the
touchstart
event. TouchEventHandlers.ontouchend
- Returns the event handling code for the
touchend
event. TouchEventHandlers.ontouchmove
- Returns the event handling code for the
touchmove
event. TouchEventHandlers.ontouchenter
- Returns the event handling code for the
touchenter
event. TouchEventHandlers.ontouchleave
- Returns the event handling code for the
touchleave
event. TouchEventHandlers.ontouchcancel
- Returns the event handling code for the
touchcancel
event.
Methods
Inherits methods from its parent, Element
.
HTMLElement.blur()
- Removes keyboard focus from the currently focused element.
HTMLElement.click()
- Sends a mouse click event to the element.
HTMLElement.focus()
- Makes the element the current keyboard focus.
HTMLElement.forceSpellCheck()
- Makes the spell checker runs on the element.
Specifications
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) View Module Определение 'HTMLElement' в этой спецификации. |
Рабочий черновик | Added the following properties: offsetParent , offsetTop , offsetLeft , offsetWidth , and offsetHeight . |
HTML Living Standard Определение 'HTMLElement' в этой спецификации. |
Живой стандарт | Added the following properties: translate , itemScope , itemType , itemId , itemRef , itemProp , properties , and itemValue .Added the following method: forceSpellcheck() .Moved the onXYZ attributes to the GlobalEventHandlers interface and added an inheritance from it. |
HTML5 Определение 'HTMLElement' в этой спецификации. |
Рекомендация | Added the following properties: dataset , hidden , tabindex , accessKey , accessKeyLabel , draggable , dropzone , contentEditable , isContentEditable , contextMenu , spellcheck , commandType , commandLabel , commandIcon , commandHidden , commandDisabled , commandChecked , style , and all the onXYZ properties.Moved the id and className properties to the Element interface. |
Document Object Model (DOM) Level 2 HTML Specification Определение 'HTMLElement' в этой спецификации. |
Устаревшая | No change from Document Object Model (DOM) Level 2 HTML Specification |
Document Object Model (DOM) Level 1 Specification Определение 'HTMLElement' в этой спецификации. |
Устаревшая | Initial definition. |
Browser compatibility
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1.0 (1.7 или ранее) | ? | 9 | ? | ? |
accessKey |
5.0 (5.0) | 17.0 | ? | ? | (Да)(535.10) |
accessKeyLabel |
8.0 (8.0) | ? | ? | ? | НетБаг WebKit 72715 |
blur() |
5.0 (5.0) | ? | ? | ? | ? |
click() |
5.0 (5.0) | ? | ? | ? | (Да)(535.24) |
dataset |
6.0 (6.0) | 9.0 | ? | 11.10 | 5.1 |
focus() |
5.0 (5.0) | ? | ? | ? | ? |
contentEditable |
3.0 (1.9) | (Да) | 5.5 | 9 | (Да) |
spellcheck |
2.0 (1.8.1) | ? | ? | ? | ? |
style |
(Да) (returns a CSS2Properties , rather than a CSSStyleDeclaration ) |
(Да) | (Да) | (Да) | (Да) |
forceSpellCheck() |
Нет | Нет | Нет | Нет | Нет |
dataset |
6.0 (6.0) | 8.0 | 11 | 11.10 | 6 |
draggable |
(Да) | ? | ? | 12.0 | ? |
dropzone |
Нет | Нет | Нет | 12.0 | Нет |
offsetLeft , offsetTop , offsetParent , offsetHeight and offsetWidth |
(Да) | ? | (Да) | ? | ? |
translate |
Нет | Нет | Нет | Нет | Нет |
itemScope , itemType , itemRef , itemId , itemProp , and itemValue |
6.0 (6.0) | Нет | Нет | 11.60 (Removed in Opera 15) |
Нет |
properties |
(Да) | ? | ? | ? | ? |
HTMLElement.ontouchstart , HTMLElement.ontouchend , HTMLElement.ontouchmove , HTMLElement.ontouchenter , HTMLElement.ontouchleave , and HTMLElement.ontouchcancel |
(Да) | (Да) | Нет | ? | (Да) |
HTMLElement.oncopy , HTMLElement.oncut , and HTMLElement.onpaste |
3.0 (1.9) | ? | ? | ? | ? |
Feature | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support |
1.0 (1.0) |
? | ? | ? | ? |
accessKey |
5.0 (5.0) | ||||
accessKeyLabel |
8.0 (8.0) | ||||
blur() |
5.0 (5.0) | ||||
click() |
5.0 (5.0) | ||||
dataset |
6.0 (6.0) | ||||
focus() |
5.0 (5.0) | ||||
HTMLElement.oncopy , HTMLElement.oncut , and HTMLElement.onpaste |
1.0 (1.9) | ? | ? | ? | ? |