5.4. Javascript Quiz¶
For the following question, you may use the textbook or your notes. You may not google other references. You have 30 minutes to complete this and you may test it as many times as you need to.
- document.body.h1
- What if there are more than one h1?
- document.h1
- No, at a minimum the h1 would be inside the body
- document.body
- Yes
- document.body.style
- Correct
- dragon
- Not far enough
- wizard
- Good Job
- castle
- Not quite, check the order of the ids
- dungeon
- No, check the ids carefully
- a string
- No, the innerText attribute is a string
- the string wizard
- No, the innerText attribute would be the string wizard
- an HTML li element in the tree
- Good job
- a CSS rule
- Nope, this has nothing to do with CSS yet.
Q-1: Which of the following are legal?
Q-2: Given the following Javascript snippet, what will the alert box say?
<html> <ul> <li id="d">dragon</li> <li id="c">wizard</li> <li id="b">castle</li> <li id="a">dungeon</li> </ul> <script type="text/javascript"> myLi = document.querySelector('#c') alert(myLi.innerHTML) </script> </html>
Q-3: Referring to the code in the previous question, what kind of thing is myLi
referring to?
Given the following HTML Add a button with a callback function that changes the
h1
from “Hello World” to “So Long CS130” When you change the message you should also arrange it so the color of the text turns blue. The rest of your page should remain unchanged.
You have attempted of activities on this page