You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Start a new project for today by downloading this link: https://github.com/yanarchy/rbk-basic/archive/each-dom.zip to your Desktop (or somewhere else). Don't forget to rename the folder to something meaningful!
8
+
2. Work on the following with your partner.
9
+
1.Look at the index.html file and discuss with a partner what the different HTML elements do. Please try to answer the following WITHOUT instructors. Please use Google or look through the previous exercises.
10
+
11
+
a. What does class mean? What is it used for?
12
+
b. What does id mean? What is it used for?
13
+
c. What is the difference between them?
14
+
d. How do you think they may be useful?
15
+
2. Try the following in your console:
16
+
17
+
document.getElementsByTagName('div');
18
+
document.getElementsByClassName('box');
19
+
document.getElementById('list');
20
+
3. What do they return?
21
+
22
+
4. Write a function called each that takes in an array and a callback. Each should loop through the array and pass each item in the array through the callback.
23
+
24
+
function each (arr, callback) {
25
+
// TODO: Your code here
26
+
}
27
+
5. Using your each, please add 'Hello World' to each of the divs with a class of 'box'. This should be written in your main.js file.
28
+
29
+
function each (arr, callback) {
30
+
// TODO: Your code here
31
+
}
32
+
Hint: You may want to look at .textContent
33
+
6. I need the picture to be smaller. Please give the picture a height of '300px'
34
+
35
+
7. Using your each function, please change all of the li elements to use the below data:
36
+
37
+
var cities = ['San Francisco', 'Cairo', 'Tokyo', 'Nairobi'];
38
+
Thus, when you are done, you should have this on your page:
39
+
tSan Francisco
40
+
Cairo
41
+
Tokyo
42
+
Nairobi
43
+
8. Bonus Challenge: Using ONLY JavaScript, please change the current image to something else (you decide!).
0 commit comments