WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

The HTML DOM Element Object


HTML DOM Nodes

In the HTML DOM (Document Object Model), everything is a node:

  • The record itself is an archive node
  • All HTML components are component nodes
  • All HTML characteristics are trait nodes
  • Text inside HTML components are content nodes
  • Comments are remark nodes

The Element Object

In the HTML DOM, the Element object speaks to a HTML element.

Element items can have child nodes of sort component hubs, content hubs, or remark nodes.

A NodeList object speaks to a rundown of hubs, similar to a HTML component's accumulation of kid nodes.

Elements can likewise have qualities. Traits are characteristic hubs (See next chapter).


Browser Support

Object
Element Yes Yes Yes Yes Yes
NodeList Yes Yes Yes Yes Yes

The Element Object and the NodeList Object is upheld in all major browsers.


Properties and Methods

The following properties and strategies can be utilized on all HTML elements:

Property/Method Description
element.accessKey Sets or returns the accesskey trait of an element
element.addEventListener() Attaches an occasion handler to the predefined element
element.appendChild() Adds another youngster hub, to a component, as the last tyke node
element.attributes Returns a NamedNodeMap of a component's attributes
element.blur() Removes center from an element
element.childElementCount Returns the quantity of tyke components a component has
element.childNodes Returns an accumulation of a component's tyke hubs (counting content and remark nodes)
element.children Returns an accumulation of a component's tyke component (barring content and remark nodes)
element.classList Returns the class name(s) of an element
element.className Sets or returns the estimation of the class quality of an element
element.click() Simulates a mouse-click on an element
element.clientHeight Returns the stature of a component, including padding
element.clientLeft Returns the width of the left fringe of an element
element.clientTop Returns the width of the best fringe of an element
element.clientWidth Returns the width of a component, including padding
nt.cloneNode() Clones an element
element.compareDocumentPosition() Compares the archive position of two elements
element.contains() Returns genuine if a hub is a relative of a hub, generally false
element.contentEditable Sets or returns whether the substance of a component is editable or not
element.dir Sets or returns the estimation of the dir property of an element
element.firstChild Returns the principal tyke hub of an element
element.firstElementChild Returns the main youngster component of an element
element.focus() Gives center to an element
element.getAttribute() Returns the predefined property estimation of a component node
element.getAttributeNode() Returns the predefined property node
element.getElementsByClassName() Returns a gathering of all youngster components with the predetermined class name
>element.getElementsByTagName() Returns a gathering of all youngster components with the predetermined tag name
element.getFeature() Returns an article which executes the APIs of a predefined feature
element.getUserData() Returns the article related to a key on an element
element.hasAttribute() Returns genuine if a component has the predefined characteristic, generally false
element.hasAttributes() Returns genuine if a component has any characteristics, generally false
element.hasChildNodes() Returns genuine if a component has any tyke hubs, generally false
element.id Sets or returns the estimation of the id characteristic of an element
element.innerHTML Sets or returns the substance of an element
element.insertBefore() Inserts another youngster hub before a predetermined, existing, tyke node
element.isContentEditable Returns genuine if the substance of a component is editable, generally false
element.isDefaultNamespace() Returns genuine if a predefined namespaceURI is the default, generally false
element.isEqualNode() Checks if two components are equal
element.isSameNode() Checks if two components are the equivalent node
element.isSupported() Returns genuine if a predefined highlight is bolstered on the element
element.lang Sets or returns the estimation of the lang characteristic of an element
element.lastChild Returns the last tyke hub of an element
>element.lastElementChild Returns the last tyke component of an element
element.namespaceURI Returns the namespace URI of an element
element.nextSibling Returns the following hub at a similar hub tree level
element.nextElementSibling Returns the following component at a similar hub tree level
element.nodeName Returns the name of a node
element.nodeType Returns the hub kind of a node
element.nodeValue Sets or returns the estimation of a node
element.normalize() Joins adjoining content hubs and evacuates void content hubs in an element
element.offsetHeight Returns the stature of a component, including cushioning, outskirt and scrollbar
element.offsetWidth Returns the width of a component, including cushioning, fringe and scrollbar
element.offsetLeft Returns the even balanced position of an element
element.offsetParent Returns the counterbalance compartment of an element
element.offsetTop Returns the vertical counterbalance position of an element
element.ownerDocument Returns the root component (report object) for an element
element.parentNode Returns the parent hub of an element
element.parentElement Returns the parent component hub of an element
element.previousSibling Returns the past hub at a similar hub tree level
element.previousElementSibling Returns the past component at a similar hub tree level
element.querySelector() Returns the principal kid component that coordinates a predefined CSS selector(s) of an element
<element.querySelectorAll() Returns all kid components that coordinates a determined CSS selector(s) of an element
element.removeAttribute() Removes a predefined trait from an element
element.removeAttributeNode() Removes a predefined trait hub, and returns the evacuated node