-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (69 loc) · 2.88 KB
/
script.js
File metadata and controls
108 lines (69 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
let quotes = [
`I live my life a quarter mile at a time`,
`I said a ten-second car, not a ten-minute car`,
`You can have any brew you want... as long as it's a Corona.`,
`You almost had me? You never had me - you never had your car!`,
`I don't have friends. I have family.`,
`It don't matter if you win by an inch or a mile. Winning's winning.`
];
document.addEventListener("DOMContentLoaded", function(event) {
// Random quote of the day generator
const randomQuote = function() {
document.querySelector('#quote-of-the-day').textContent = `"${quotes[Math.floor(Math.random() * quotes.length)]}"`;
};
randomQuote();
// Do all of your work inside the document.addEventListener
// Part 1
const mainTitle = document.getElementById("main-title");
mainTitle.textContent = "Hello,I'm DOM";
// Part 2
const bodyEl = document.querySelector('body');
bodyEl.style.backgountColor = 'grey';
// Part 3
const favoriteThings = document.getElementById('favorite-things');
const lastListItem = favoriteThingsList.lastElementChild;
favoriteThingsList.removeChild(lastListItem);
// Part 4
const specialTitle = document.getElementAll('.special-title'){
for(let i = 0; i < specialTitle.length; i++)
specialTitle.style.fontsize = '2rem'};
// Part 5
const pastRaces = document.getElement('Past Races');
const listItems = pastRacesList.getElementByTagName('li');
for(let i = 0; i < listItem.length; i++){
if (listItem.textContent.includes('Chicago')) {
pastRacesList.removeChild(listItem);
break;
}
}
// Part 6
const pastRacesList = document.getElementById('past-races');
const newCity = 'Washington DC';
const newListItem = document.createElement('li');
newListItem.textContent = newCity;
pastRacesList.appendChild(newListItem);
// Part 7
const blogPostsContainer = document.getElementById('blog-posts');
const newBlogPost = document.createElement('div');
newBlogPost.classList.add('blog-post');
const heading = document.createElement('div');
heading.textContent = `Exploring ${newCity};
const paragraph = document.createElement('p');
paragraph.textContent = `When I visited ${newCity}, I found interesting buildings.`;
newBlogPost.appendChild(heading);
newBlogPost.append(paragraph);
blog PostsContainer.appendChild(newBlogPost);
// Part 8
const quoteTitle = document.querySelector('#quote-title');
quoteTitle.addEventListener('click', randomQuote);
// Part 9
const blogPosts = document.querySelectorAll('.blog-post');
blogPosts.forEach(blogPost => {
blogPost.addEventListener('mouseout, () => {
blogPost.classList.toggle('purple');
});
blogPost.addEventListener( 'mouseenter',() => {
blogPost.classList.toggle('red');
});
});
});