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
To assemble a collection of all <p>s in the document, you write document.getElementsByTagName(__) | "p" | •p• | |
To assemble a collection of all elements in the document that share the class "special", you write document._______________("special") | getElementsByClassName | getElementsByClassName | |
Complete the statement to assemble a list of spans in the document. | let allSpans = _____________; | document.getElementsByClassName("span") | document\.getElementsByClassName\(•span•\) |
Complete the statement to assemble a list of all elements in the document that share the class "emphasize". | let emElements = ________________; | document.getElementsByClassName("emphasize") | document\.getElementsByClassName\(•emphasize•\) |
A <div> has been assigned to a variable, targetDiv. Get a collection of tables within the <div>. Assign the collection to a variable that hasn't been declared beforehand. Make up the name of the variable. | let tableCollection = targetDiv.getElementsByTagName("table"); | let[a-z_$][a-zA-Z0-9_$]*=targetDiv\.getElementsByTagName\(•table•\); | |
A table has been assigned to a variable, tbl. Get a collection of elements within the table that share the class "prominent". Assign the collection to a variable that hasn't been declared beforehand. Make up the name of the variable. | let boldEls = tbl.getElementsByClass("prominent"); | let[a-z_$][a-zA-Z0-9_$]*=tbl\.getElementsByClass\(•prominent•\); | |
A collection of anchors has been assigned to a variable, aCollection. Get the href attribute of the second anchor in the collection. Assign it to a variable that hasn't been declared beforehand. Make up the name of the variable. | let lnk = aCollection[1].getAttribute("href"); | let[a-z_$][a-zA-Z0-9_$]*=aCollection\[1\]\.getAttribute\(•href•\); | |
A collection of elements that share the same class has been assigned to a variable, normies. Get the node name of the first element in the collection. Display it in the console. | console.log(normies[0].nodeName); | console\.log\(normies\[0\]\.nodeName\); | |
|
|||
|