Example: Node properties

For now, as mentioned in the discussion about the canvas, we will place the script elementAn HTML element that contains a script, tag name <code>script</code>. in the body element.

Here we are only considering element nodes, which will have the following values:

Property Value
nodeType 1
nodeName tag name in upper case
nodeValue null

Try adding variables for other nodes in the document as well as printing out the values of their various properties.

Note:

Hints:

  • undefined
1
2
var docNode = document.documentElement;
var itemNode = document.getElementById("para");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX