XML DOM HTMLElement Object

Het HTMLElement-object vertegenwoordigt een element in HTML.

Eigenschappen van het HTMLElement-object

Elk element in een HTML-document heeft een eigenschap die overeenkomt met de HTML-eigenschap van het element. Hier worden alle eigenschappen vermeld die door alle HTML-markeringen worden ondersteund. Andere eigenschappen zijn specifiek voor een bepaald HTML-markeringstype. Het HTMLElement-object erfde Node and Element Standaard eigenschappen van het object, die ook de hierboven beschreven niet-standaard eigenschappen implementeren:

className

Stelt het element van de class-eigenschap vast. Let op: de naam van deze eigenschap is niet "class", omdat "class" een voorbehouden woord in JavaScript is.

Type: String. Status: writable.

currentStyle

Deze specifieke, IE-gerichte eigenschap wordt toegepast op de cascadegroep van alle CSS-eigenschappen van het element. Het is een alternatief voor Window.getComputedStyle() specifiek voor IE.

Type: String. Status: writable.

dir

Stelt het element van de dir-eigenschap vast, die de richting van de tekst van het document declareert.

Type: String. Status: writable.

id

Stelt het element van de id-eigenschap vast.

Type: String. Status: writable.

innerHTML

Stelt het element van de string die het element bevat vast, inclusief de begin- en eindmarkeringen van het element zelf niet. Het opzoeken van deze eigenschap zal het inhoud van het element teruggeven als een HTML-tekstreeks. Als deze eigenschap wordt ingesteld op een HTML-tekstreeks, kan de inhoud van het element worden vervangen met de HTML-parserweergave. Deze eigenschap kan niet worden ingesteld tijdens het laden van het document. Dit is een niet-standaard eigenschap die afkomstig is van IE4, maar wordt ondersteund door alle moderne browsers.

Type: String. Status: writable.

lang

Het element van de lang-eigenschap declareert de taalcode van de inhoud van het element.

Type: String. Status: writable.

offsetHeight, offsetWidth

返回元素的高度和宽度,以像素为单位。这是非标准的但却得到很好支持的属性。

scrollHeight, scrollWidth

offsetHeight, offsetWidth

Returns the height and width of the element in pixels. This is a non-standard but well-supported property.

scrollHeight, scrollWidth

offsetLeft

Returns the offset, in pixels, from the left boundary of the current element to the left boundary of its containing element.

scrollHeight, scrollWidth

offsetTop

Returns the offset, in pixels, from the top boundary of the current element to the top boundary of its containing element.

Type:Node. Status: read-only.

offsetParent

Returns a reference to the nearest dynamically positioned containing element, with all offsets determined by that element. If the element's style.display is set to none, this property returns null. This is a non-standard but well-supported property.

scrollHeight, scrollWidth

Type: int. Status: read-only. Returns the complete height and width of the element in pixels. When an element has a scrollbar (such as due to the CSS overflow property), these properties are different from offsetHeight and offsetWidth, offsetHeight and offsetWidth only report the size of the visible part of the element. This is a non-standard but well-supported property.

scrollTop, scrollLeft

Type: int. Status: writable. Sets or returns the number of pixels scrolled to the left or top edge of the element. These pixels are only useful when the element has a scrollbar, for example, when the element's CSS overflow property is set to auto. These properties are also only defined on the <body> or <html> tags (this is related to the browser), and together they determine the position of the scrolling document. Note that these properties do not specify the scroll amount of an <iframe> tag. This is a non-standard but well-supported property.

style

Returns the value of the style attribute set for the current element's inline CSS style. Note that the value of this attribute is not a string.

Type:CSS2Properties. Status: read-only.

title

Specifies the title attribute of the element. When the mouse hovers over the element, many browsers display the value of this attribute in the element's 'tool tip'.

Type: String. Status: writable.

The methods of the HTMLElement object

The HTMLElement object inherits Node and Element The standard methods of the object. Certain types of elements implement methods specific to the marker, CodeW3C.com at HTML DOM referentiemanualEach marker reference page provides information about these methods.

Most modern browsers also implement the following non-standard methods:

Methode Beschrijving
scrollIntoView() Scroll het document. Maak het element zichtbaar aan de top of onderkant van het venster.

HTMLElement object event handlers

Alle HTML-elementen die reacties geven op muis- en toetsenbordgebeurtenissen, kunnen de hier vermelde event handlers activeren. Sommige elementen, zoals links en knoppen, voeren standaardacties uit wanneer deze gebeurtenissen optreden. Voor dergelijke elementen zijn meer details beschikbaar inSpecifieke element referentiepagina'sgevonden.

Raadpleeg HTML evenement eigenschappen referentiemanualom meer te weten te komen over HTML event handlers.

Hoe kun je meer gedetailleerde informatie krijgen over het HTMLElement-object?

In de HTML DOM referentiemanual van CodeW3C.com hebben we speciale referentiepagina's gemaakt voor de DOM-objecten die overeenkomen met HTML-markeringen:

HTML DOM referentiemanual

Gerelateerde pagina's

XML DOM referentiemanual:Document object

XML DOM referentiemanual:Document.getElementById()

XML DOM referentiemanual:Document.getElementsByTagName()