HTML and CSS Reference
In-Depth Information
Objective review
Answer the following questions to test your knowledge of the information in this objective.
You can find the answers to these questions and explanations of why each answer choice is
correct or incorrect in the “Answers” section at the end of this chapter.
Which of the following JavaScript methods can't be used to select an element in the
DOM?
A. getElementById
B. querySelector
C. getElementByClassName
D. queryAll
1.
Which line of JavaScript successfully retrieves only the image element with the ID
myDog from the following HTML? Choose all that apply.
2.
<form>
<div id="main" class="mainStyle">
<p id="dogs">
This is a web page about dogs. Here is my dog picture:
<img src="dog.jpg" id="myDog" class="thumb"/>
Here is a picture of my friend's dog:
<img src="dog.jpg" id="myfriendsDog" class="thumb"/>
</p>
</div>
</form>
A. document.getElementbyId(“myDog”);
B. <p>.getChildNode(“img”);
C. document.getElementbyId(“dogs).querySelector (“thumb”);
D. document.querySelectorAll(“thumb”);
To hide an element in the DOM and still be able to add it back later, what should you
do?
3.
Nothing, because the DOM is always available in a static form.
A.
Keep a reference to the removed node to be able to add it back.
B.
Call the document.restoreNodes method.
C.
You can't add an element back after it's removed.
D.
 
Search WWH ::




Custom Search