XML DOM - HTMLElement-Objekt
- Vorherige Seite DOM HTMLDocument
- Nächste Seite DOM NamedNodeMap
Das HTMLElement-Objekt stellt ein Element in HTML dar.
Attribute des HTMLElement-Objekts
Jedes Element in einem HTML-Dokument hat ein Attribut, das mit dem HTML-Attribut des Elements korrespondiert. Hier sind alle Attribute aufgeführt, die von allen HTML-Marken unterstützt werden. Andere Attribute sind spezifisch für eine bestimmte HTML-Marke. Der HTMLElement-Objekt vererbt Node and Element Standardattribute des Objekts, die auch die folgenden nicht standardisierten Attribute implementieren:
- className
-
Es legt das class-Attribut des Elements fest. Beachten Sie: Der Name dieses Attributs ist nicht "class", da "class" ein reserviertes Wort in JavaScript ist.
Type: String. Status: writable.
- currentStyle
-
Dieses spezifische für IE bestimmte Attribut wird auf die Kaskadengruppe aller CSS-Attribute des Elements angewendet. Es ist eine IE-spezifische Alternative zu Window.getComputedStyle().
Type: String. Status: writable.
- dir
-
Es legt das dir-Attribut des Elements fest, das die Richtung des Dokumententextes deklariert.
Type: String. Status: writable.
- id
-
Es legt das id-Attribut des Elements fest. In einem Dokument haben keine zwei Elemente denselben id-Wert.
Type: String. Status: writable.
- innerHTML
-
Es legt fest, welche Zeichenfolge ein Element enthält, ohne den Start- und Endtag des Elements selbst. Die Abfrage dieses Attributs gibt den Inhalt des Elements als HTML-Textkette zurück. Wenn dieses Attribut auf eine HTML-Textkette gesetzt wird, kann der Inhalt des Elements durch die Darstellungssyntax von HTML ersetzt werden. Dieses Attribut kann nicht während des Ladens der Dokument gesetzt werden. Dies ist ein nicht standardisiertes Attribut, das von IE4 stammt und von allen modernen Browsern unterstützt wird.
Type: String. Status: writable.
- lang
-
Die lang-Attribut des Elements deklariert den Sprachcode des Inhalts des Elements.
Type: String. Status: writable.
- offsetHeight, offsetWidth
-
返回元素的高度和宽度,以像素为单位。这是非标准的但却得到很好支持的属性。
Type: int. Status: read-only. Returns the complete height and width of the element in pixels. When an element has a scrollbar (for example, due to the CSS overflow property), these properties are different from offsetHeight and offsetWidth, as offsetHeight and offsetWidth only report the size of the visible part of the element. This is a non-standard but well-supported property.
- offsetLeft
-
Returns the offset in pixels from the left boundary of the current element to the left boundary of its containing element.
Type: int. Status: read-only. Returns the complete height and width of the element in pixels. When an element has a scrollbar (for example, due to the CSS overflow property), these properties are different from offsetHeight and offsetWidth, as offsetHeight and offsetWidth only report the size of the visible part of the element. This is a non-standard but well-supported property.
- offsetTop
-
Returns the offset in pixels from the top boundary of the current element to the top boundary of its containing element.
Type: int. Status: read-only. Returns the complete height and width of the element in pixels. When an element has a scrollbar (for example, due to the CSS overflow property), these properties are different from offsetHeight and offsetWidth, as offsetHeight and offsetWidth only report the size of the visible part of the element. This is a non-standard but well-supported property.
- offsetParent
-
Type:Node. Status: read-only.
- Returns a reference to the nearest dynamically positioned containing element, with all offsets determined relative to 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 (for example, due to the CSS overflow property), these properties are different from offsetHeight and offsetWidth, as 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 document's <body> or <html> tags (this is browser-dependent) 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 tag, CodeW3C.com at HTML DOM ReferenzhandbuchThe reference pages for each tag provide information about these methods.
Most modern browsers also implement the following non-standard methods:
Methode | Beschreibung |
---|---|
scrollIntoView() | Scrollt das Dokument. Lässt das Element an der Ober- oder Unterseite des Fensters erscheinen. |
Ereignis-Handler des HTMLElement-Objekts
Alle HTML-Elemente, die auf Maus- und Tastaturereignisse reagieren, können die hier aufgelisteten Ereignis-Handler auslösen. Einige Elemente, wie Links und Schaltflächen, führen bei Auftreten dieser Ereignisse Standardaktionen aus. Für solche Elemente sind mehr Details inReferenzseiten für spezifische Elementegefunden.
Siehe HTML-Ereignis-Attribute Referenzhandbuchum mehr über die HTML-Ereignis-Handler zu erfahren.
Wie kann man detaillierte Informationen über das HTMLElement-Objekt erhalten?
In unserem HTML DOM Referenzhandbuch auf CodeW3C.com haben wir spezielle Referenzseiten für die DOM-Objekte der HTML-Symbole erstellt:
Verwandte Seiten
XML DOM Referenzhandbuch:Document Objekt
XML DOM Referenzhandbuch:Document.getElementById()
XML DOM Referenzhandbuch:Document.getElementsByTagName()
- Vorherige Seite DOM HTMLDocument
- Nächste Seite DOM NamedNodeMap