javaScript html dom element object Properties Methods

in html dom the element object represents an html element.

a nodeList object represents a list of nodes, like an html element's collection of child nodes

the node and NodeList object is supported in all browsers.

JavaScript element object properties

the following properties can be used on all html elements:

element.attributesreturns a collection of the attributes
element.childNodesreturns a NodeList of child nodes for an element
element.classNamesets or returns the class attribute of an element
element.idsets or returns the id of an element
element.langsets or returns the language code for an element
element.dirsets or returns the text direction of an element
element.firstChildreturns the first child of an element
element.lastChildreturns the last child of an element
element.innerhtmlsets or returns the content of an element
element.namespaceurireturns the namespace uri of an element
element.nodeNamereturns the name of an element
element.nodeTypereturns the type of an element
element.nodeValuesets or returns the value of an element
element.ownerDocumentreturns the root element
element.parentNodereturns the parent node of an element
element.previousSiblingreturns the previous element at the same node tree level
element.nextSiblingreturns the next element at the same node tree level
element.tabIndexsets or returns the tab order of an element
element.textContentsets or returns the text content of a node and its descendants
element.tagNamereturns the tag name of an element
element.titlesets or returns the title attribute of an element
nodelist.lengthreturns the number of elements in the nodeList

JavaScript element object methods

the following methods can be used on all html elements:

element.appendChild()appends the node in newchild as the last child of the current element
element.cloneNode()clones an element
element.getAttribute()returns the specified attribute value of an element node
element.getAttributeNode()returns the specified attribute node
element.hasAttribute()returns true if an element has the attribute, otherwise false
element.hasAttributes()returns true if an element has any attributes, otherwise false
element.hasChildNodes()returns true if an element has any child nodes, otherwise false
element.insertBefore()insert a new child node before a specified, existing, child node
element.isSupported()returns true if a specified feature is supported on the element otherwise false
element.isSameNode()Checks if two elements are the same node
element.isEqualNode()Checks if two elements are equal
element.normalize()joins adjacent text nodes and removes empty text nodes in an element
element.removeAttribute()removes a specified attribute from an element
element.removeAttributeNode()removes a specified attribute node, and returns the removed node
element.removeChild()removes a child node from an element
element.replaceChild()replaces a child node in an element
element.setAttribute()sets the specified attribute to the specified value
element.setAttributeNode()sets the specified attribute node
element.toString()Converts an element to a string
nodelist.item()returns the node at the specified index in a NodeList