Access to the DOM node

Using only the DOM API, what are the different ways I can access the node?

For example, I know that I can call document.getElementById("header");. I need a complete list of ways to access this node.

+3
source share
2 answers

“access” can take two forms. Properties and methods.

In this list, m is a node object (HTML element). Some properties:

  • m.innerHTML - text
  • m.nodeName - name
  • m.nodeValue - value
  • m.parentNode - parent node
  • m.childNodes - child nodes
  • m.attributes - attribute nodes

Some methods:

  • m.getElementById (id) - element with id
  • m.getElementsByTagName (name) - get all elements by tag name
  • m.appendChild(node) - node m
  • m.removeChild(node) - node m

"":

  • document.documentElement - root node
  • document.body - body

. , .length .. , .

EDIT: : http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html

EDIT2: HTML 1 : http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html

EDIT3: ECMA script: http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html

+4

, , node. , , .

: , , , , , childNodes, , , , , , , , , , , tBodies

: body, caption, document, documentElement, firstChild, firstElementChild, frameElement, lastChild, lastElementSibling, nextElementSibling, nextSibling, offsetParent, ownerDocument, parentElement, parentNode, previousElementSibling, previousSibling, tFoot, tHead

: getElementById, getElementsByClassName, getElementsByName, getElementsByTagName, getElementsByTagNameNS

: , JavaScript

+2

Source: https://habr.com/ru/post/1759390/


All Articles