HTMLElement

HTMLElement 介面表示了所有的 HTML 元素。部分元素直接實作了此介面,其它則是實作繼承自 HTMLElement 的子介面。

EventTarget Node Element HTMLElement

屬性

Inherits properties from its parent, Element, and implements those from GlobalEventHandlers and TouchEventHandlers.

HTMLElement.accessKey (en-US)

Is a DOMString representing the access key assigned to the element.

HTMLElement.accessKeyLabel (en-US) Read only

Returns a DOMString containing the element's assigned access key.

HTMLElement.contentEditable (en-US)

Is a DOMString, where a value of "true" means the element is editable and a value of "false" means it isn't.

HTMLElement.isContentEditable (en-US) Read only

Returns a Boolean (en-US) that indicates whether or not the content of the element can be edited.

HTMLElement.contextMenu (en-US)

Is a HTMLMenuElement (en-US) representing the contextual menu associated with the element. It may be null.

HTMLElement.dataset (en-US) Read only

Returns a DOMStringMap (en-US) with which script can read and write the element's custom data attributes (en-US) (data-*) .

HTMLElement.dir (en-US)

Is a DOMString, reflecting the dir 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 Read only

Returns a DOMSettableTokenList reflecting the dropzone global attribute and describing the behavior of the element regarding a drop operation.

HTMLElement.hidden (en-US)

Is a Boolean indicating if the element is hidden or not.

HTMLElement.itemScope 實驗性質

Is a Boolean representing the item scope.

HTMLElement.itemType Read only 實驗性質

Returns a DOMSettableTokenList

HTMLElement.itemId 實驗性質

Is a DOMString representing the item ID.

HTMLElement.itemRef Read only 實驗性質

Returns a DOMSettableTokenList

HTMLElement.itemProp Read only 實驗性質

Returns a DOMSettableTokenList

HTMLElement.itemValue 實驗性質

Returns a Object representing the item value.

HTMLElement.lang

Is a DOMString representing the language of an element's attributes, text, and element contents.

HTMLElement.offsetHeight (en-US) Read only 實驗性質

Returns a double containing the height of an element, relative to the layout.

HTMLElement.offsetLeft (en-US)Read only 實驗性質

Returns a double, the distance from this element's left border to its offsetParent's left border.

HTMLElement.offsetParent (en-US)Read only 實驗性質

Returns a Element that is the element from which all offset calculations are currently computed.

HTMLElement.offsetTop (en-US)Read only 實驗性質

Returns a double, the distance from this element's top border to its offsetParent's top border.

HTMLElement.offsetWidth (en-US)Read only 實驗性質

Returns a double containing the width of an element, relative to the layout.

HTMLElement.properties Read only 實驗性質

Returns a HTMLPropertiesCollection

HTMLElement.spellcheck

Is a Boolean that controls spell-checking (en-US). It is present on all HTML elements, though it doesn't have an effect on all of them.

HTMLElement.style (en-US)

Is a CSSStyleDeclaration, an object representing the declarations of an element's style attributes.

HTMLElement.tabIndex (en-US)

Is a long representing the position of the element in the tabbing order.

HTMLElement.title (en-US)

Is a DOMString containing the text that appears in a popup box when mouse is over the element.

HTMLElement.translate 實驗性質

Is a Boolean representing the translation.

事件處理器

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 (en-US) 非標準

Returns the event handling code for the copy event (bug 280959).

HTMLElement.oncut (en-US) 非標準

Returns the event handling code for the cut event (bug 280959).

HTMLElement.onpaste (en-US) 非標準

Returns the event handling code for the paste event (bug 280959).

TouchEventHandlers.ontouchstart 非標準

Returns the event handling code for the touchstart (en-US) event.

TouchEventHandlers.ontouchend 非標準

Returns the event handling code for the touchend (en-US) event.

TouchEventHandlers.ontouchmove 非標準

Returns the event handling code for the touchmove (en-US) 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.

方法

Inherits methods from its parent, Element.

HTMLElement.blur() (en-US)

Removes keyboard focus from the currently focused element.

HTMLElement.click()

Sends a mouse click event to the element.

HTMLElement.focus() (en-US)

Makes the element the current keyboard focus.

HTMLElement.forceSpellCheck() (en-US) 實驗性質

Runs the spell checker on the element's contents.

規範

Specification
HTML Standard
# htmlelement

瀏覽器相容性

BCD tables only load in the browser

參見