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
The three types of nodes I've covered in the book are elements, text, and _____. | comments | comments | |
An attribute is a ______ of a node. | property | property | |
An image has been assigned to a variable, pic. Assign the value of its source to a variable, picSource, which hasn't been declared beforehand. | let picSource = pic.getAttribute("src"); | letpicSource=pic\.getAttribute\(•src•\); | |
A paragraph has been assigned to a variable, pgraph. Assign the value of its class or classes to a variable, classes, that hasn't been declared beforehand. | let classes = pgraph.getAttribute("class"); | letclasses=pgraph\.getAttribute\(•class•\); | |
A div has been assigned to a variable, parentEl. This element is followed by whitespace, then a comment. In the console, display the node name of the comment. | console.log(parentEl.childNodes[1].nodeName); | console\.log\(parentEl\.childNodes\[1\]\.nodeName\); | |
A form has been assigned to a variable, frm. Display the value of its id attribute in the console. | console.log(frm.getAttribute("id")); | console\.log\(frm\.getAttribute\(•id•\)\); | |
A paragraph has been assigned to a variable, pgraph. Delete its class attribute. | pgraph.removeAttribute("class"); | pgraph\.removeAttribute\(•class•\); | |
An element has been assigned to a variable, el. If the element's third element child is an <h4> element, display the <h4>'s class or classes in the console. Do it in three lines of code. Use the children keyword. | if (el.children[2].nodeName === "h4") { console.log(el.children[2].getAttribute("class")); } |
if\(el\.children\[2\]\.nodeName===•h4•\){[\r\n]console\.log\(el\.children\[2\]\.getAttribute\(•class•\)\);[\r\n]} | |
|
|||
|