<!DOCTYPE html>
<html>
<head>
<title>Sample page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
document
Document Node
|
||||
<!DOCTYPE html>
Document Type Node
|
||||
<html>
Element Node
|
||||
<head>
Element Node
|
||||
<title>
Element Node
|
||||
Sample Page
Text Node
|
||||
<body>
Element Node
|
||||
<h1>
Element Node
|
||||
Hello World
Text Node
|
Chick the type by doing node.nodeType
node.nodeType === Node.ELEMENT_NODEList of node types
node.nodeName === 'H1'
node.nodeType === Node.TEXT_NODE // 3
node.nodeValue // get the text value
node.getAttribute('attribute_name')
node.setAttribute('attribute_name', value)
Returns the inner HTML as a string