1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
Fill in the blank to get the node name. | let nameOfNode = selectedNode._______; | nodeName | nodeName |
Fill in the blank to get the node name of the second element of selectedElement. | let nameOfNode = __________________; | selectedElement.children[1].nodeName; | selectedElement\.children\[1\]\.nodeName; |
Here is some markup, followed by a JavaScript statement. What will be displayed in the Chrome console? |
<div> <h2>The slow loris</h2> <p>Few mammals are slower than the slow loris.</p> </div> console.log(document.querySelector("div").children[1].nodeName); |
P | [P|p] |
An element has been assigned to a variable, el. Display the name of its parent in the console. | console.log(el.parentNode.nodeName); | console\.log\(el\.parentNode\.nodeName\); | |
What is the node name of a text node, as displayed in the Chrome console? | #text | #text | |
Below is the markup. The <p> element has been assigned to a variable, pgraph. Display the node name of the element's child in the console. Remember, the keyword children gives you a collection of element nodes only, so it won't work for getting a node that isn't an element. | <p>Hello World!</p> | console.log(pgraph.childNodes[0].nodeName); | console\.log\(pgraph\.childNodes\[0\]\.nodeName\); |
Below is some markup. The list item has been assigned to a variable, item. In a single statement, work your way up the DOM tree to the <div>. Assign its node name to a variable that hasn't been declared beforehand. Make up the name of the variable. |
<div> <ul> <li>The only item</li> </ul> </div> |
let nName = item.parentNode.parentNode.nodeName; | let[a-z_$][a-zA-Z0-9_$]*=item\.parentNode\.parentNode\.nodeName; |
Find the name of the first child element of the first child element of an element that has been assigned to the variable el. Assign the name to a variable that hasn't been declared beforehand. Make up the name of the variable. | let ch = el.children[0].children[0].nodeName; | let[a-z_$][a-zA-Z0-9_$]*=el\.children\[0\]\.children\[0\]\.nodeName; | |
|
|||
|