HTML & CSS Wiki
Advertisement

In HTML and XML, an element is an individual component of a document. Documents are composed of a tree of elements and other nodes, such as text nodes. Each element can have attributes specified. Elements can also have content, including other elements and text. Elements often represent semantics, or meaning. For example, the <title> element represents the title of the document. In code, elements are represented by tags.

Line of inheritance:
Element/~

Every instance of this interface will, in practice, also implement EventTarget, so those members are also documented here.

Properties[]

These properties are available on all Element instances.

Methods[]

These methods are available on all Element instances.

addEventListener[]

Data type function
Return type void
Parameter list type (string), listener (function), useCapture (boolean)
Standard DOM Level 2 Events, DOM Level 3 Events
Documentation Mozilla Microsoft

Registers listener to be called when an event of the specified type occurs on this element or a descendant. (type does not start with "on.") useCapture indicates which phases the listener may be invoked in. When in doubt, pass false as the third parameter; see here for a detailed explanation.

For Internet Explorer 8 and before, see attachEvent below.

attachEvent[]

Data type function
Return type boolean
Parameter list type (string), listener (function)
Standard none
Documentation Microsoft

Registers listener to be called when an event of the specified type occurs on this element or a descendant. (type does start with "on.") This method is essentially equivalent to calling addEventListener with false as the third parameter, except that this === window is always true within the listener, and event is a global variable.

getElementsByTagName[]

Data type function
Return type NodeList
Parameter list tagName (string)
Standard DOM Level 1 Core, DOM Level 2 Core
Documentation Mozilla, Microsoft

Finds every descendant of this element which has the specified tagName and is contained by the current element. The asterisk ("*") matches all elements below this one.

See also[]

Document.getElementsByTagName

getElementsByTagNameNS[]

Data type function
Return type NodeList
Parameter list tagName (string), namespace (string)
Standard DOM Level 2 Core
Documentation Mozilla

Finds every descendant of this element which has the specified tagName and namespace and is contained by the current element. If the name is only the asterisk ("*"), all elements below this one in the specified namespace will be returned.

See also[]

Document.getElementsByTagNameNS

This page uses Creative Commons Licensed content from Wikipedia (view authors).
Advertisement