-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom-warmups.html
More file actions
274 lines (248 loc) · 9.62 KB
/
dom-warmups.html
File metadata and controls
274 lines (248 loc) · 9.62 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!--Justin's WormUPs-->
<!--<!DOCTYPE html>-->
<!--<html lang="en">-->
<!--<head>-->
<!-- <meta charset="UTF-8">-->
<!-- <title>DOM Manipulation Warmups</title>-->
<!-- <style>-->
<!-- .letter {-->
<!-- cursor: crosshair;-->
<!-- }-->
<!-- .title-letter {-->
<!-- color: firebrick;-->
<!-- font-size: 3em;-->
<!-- }-->
<!-- </style>-->
<!--</head>-->
<!--<body>-->
<!--<h1>-->
<!-- <span class="letter">D</span><span class="letter">O</span><span class="letter">M</span>-->
<!-- <span class="letter">W</span><span class="letter">a</span><span class="letter">r</span><span class="letter">m</span>-->
<!-- <span class="letter">U</span><span class="letter">p</span><span class="letter">s</span>-->
<!--</h1>-->
<!--<h3>Letter from title in lowercase: <span class="title-letter"></span></h3>-->
<!--<h1>The sum is: <span id="sum-output">0</span></h1>-->
<!--<label for="number">Number</label>-->
<!--<input id="number" type="number" name="number" min="0" max="5" value="0">-->
<!--<button id="add-btn">Add</button>-->
<!--<!– Include the CDN script for jQuery below –>-->
<!--<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>-->
<!--<script>-->
<!-- "use strict";-->
<!-- // TODO: add the needed JS so that the number selected in the number input will be added to the number in the span-->
<!-- $("#add-btn").click(function (){-->
<!-- let $showNumbers = $("#number").val();-->
<!-- let $showText = $("#sum-output").text();-->
<!-- let $result = parseInt($showNumbers) + parseInt($showText)-->
<!-- $("#sum-output").text($result);-->
<!-- })-->
<!-- /*-->
<!-- TODO: add the needed JS so that when the cursor hovers over a letter in the h1 title,-->
<!-- the letter will appear in the span with a class of `title-letter`, in lowercase.-->
<!-- When the cursor is not hovering over a letter in the h1 title, no letter should be-->
<!-- displayed in the span with a class of `title-letter`.-->
<!-- */-->
<!-- $(".letter").hover(function () {-->
<!-- let $showLowerCase = $(this).text().toLowerCase();-->
<!-- $(".title-letter").text($showLowerCase);-->
<!-- },-->
<!-- function () {-->
<!-- $(".title-letter").text('')-->
<!-- })-->
<!--</script>-->
<!--</body>-->
<!--</html>-->
<!--Casey's DOM WormUPs-->
<!--<!DOCTYPE html>-->
<!--<html lang="en">-->
<!--<head>-->
<!-- <meta charset="UTF-8">-->
<!-- <title>DOM DOM DOM DOMMMMMMMM</title>-->
<!--</head>-->
<!--<body>-->
<!--<div id="list-container">-->
<!-- <ul id="list">-->
<!-- <li data-value="1"></li>-->
<!-- <li data-value="2"></li>-->
<!-- <li data-value="3"></li>-->
<!-- <li data-value="4"></li>-->
<!-- <li data-value="5"></li>-->
<!-- <li data-value="6"></li>-->
<!-- <li data-value="7"></li>-->
<!-- <li data-value="8"></li>-->
<!-- <li data-value="9"></li>-->
<!-- </ul>-->
<!--</div>-->
<!--<div id="binary-container">-->
<!-- <h2 id="#binary-display"></h2>-->
<!--</div>-->
<!--<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>-->
<!--<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>-->
<!--<script>-->
<!-- {-->
<!-- "use strict";-->
<!-- // When the user clicks on an li, set the text value to either 0 or 1-->
<!-- // If the last li clicked was set to 0 then the next is set to 1 (and vice versa)-->
<!-- // When the last li has been set, display the li text values to the below <h2>-->
<!-- // HINT: remove the event handler from the li once it is clicked :)-->
<!-- function addClickEvents(){-->
<!-- let isZero = true;-->
<!-- let counter = 0;-->
<!-- let listItems = $("#list").children();-->
<!-- listItems.click(function (e){-->
<!-- let liValue = isZero ? 0 : 1;-->
<!-- $(this).text(liValue);-->
<!-- isZero = !isZero;-->
<!-- counter++;-->
<!-- if (counter === listItems.length){-->
<!-- displayBinary();-->
<!-- }-->
<!-- $(this).off();-->
<!-- });-->
<!-- }-->
<!-- function displayBinary(){-->
<!-- let listItems = $("#list").children();-->
<!-- let binaryValues = [];-->
<!-- listItems.each(function (){-->
<!-- binaryValues += $(this).text();-->
<!-- })-->
<!-- let outputStr = binaryValues.split(' ')-->
<!-- .map(bin => String.fromCharCode(parseInt(bin, 2)))-->
<!-- .join('')-->
<!-- }-->
<!-- addClickEvents();-->
<!-- }-->
<!--</script>-->
<!--</body>-->
<!--Justin's DOM Worm up-->
<!--<!DOCTYPE html>-->
<!--<html lang="en">-->
<!--<head>-->
<!-- <meta charset="UTF-8">-->
<!-- <title>DOM Manipulation Warmups</title>-->
<!-- <style>-->
<!-- .letter {-->
<!-- cursor: crosshair;-->
<!-- }-->
<!-- .title-letter {-->
<!-- color: firebrick;-->
<!-- font-size: 3em;-->
<!-- }-->
<!-- .bg-colors li {-->
<!-- cursor: pointer;-->
<!-- }-->
<!-- </style>-->
<!--</head>-->
<!--<body>-->
<!--<h1>-->
<!-- <span class="letter">D</span><span class="letter">O</span><span class="letter">M</span>-->
<!-- <span class="letter">W</span><span class="letter">a</span><span class="letter">r</span><span class="letter">m</span>-->
<!-- <span class="letter">U</span><span class="letter">p</span><span class="letter">s</span>-->
<!--</h1>-->
<!--<h3>Letter from title in lowercase: <span class="title-letter"></span></h3>-->
<!--<h3>The sum is: <span id="sum-output">0</span></h3>-->
<!--<label for="number">Number</label>-->
<!--<input id="number" type="number" name="number" min="0" max="5" value="0">-->
<!--<button id="add-btn">Add</button>-->
<!--<hr>-->
<!--<ul class="bg-colors">-->
<!-- <li>Red</li>-->
<!-- <li>Green</li>-->
<!-- <li>Blue</li>-->
<!-- <li>yellow</li>-->
<!--</ul>-->
<!--<!– Include the CDN script for jQuery below –>-->
<!--<script-->
<!-- src="http://code.jquery.com/jquery-2.2.4.min.js"-->
<!-- integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="-->
<!-- crossorigin="anonymous"></script>-->
<!--<script>-->
<!-- "use strict";-->
<!-- // TODO: add the needed JS so that the number selected in the number input will be added to the number in the span-->
<!-- $('#add-btn').click(function() {-->
<!-- let numVal = parseInt($('#number').val());-->
<!-- let currVal = parseInt($('#sum-output').text());-->
<!-- $('#sum-output').text(numVal + currVal);-->
<!-- });-->
<!-- /*-->
<!-- TODO: add the needed JS so that when the cursor hovers over a letter in the h1 title,-->
<!-- the letter will appear in the span with a class of `title-letter`, in lowercase.-->
<!-- When the cursor is not hovering over a letter in the h1 title, no letter should be-->
<!-- displayed in the span with a class of `title-letter`.-->
<!-- */-->
<!-- $('.letter').hover(-->
<!-- function() {-->
<!-- let letter = $(this).text().toLowerCase();-->
<!-- $('.title-letter').text(letter);-->
<!-- },-->
<!-- function() {-->
<!-- $('.title-letter').text('');-->
<!-- }-->
<!-- );-->
<!-- /*-->
<!-- TODO: When an li in the ul with a class of `bg-colors` is double-clicked,-->
<!-- the background color of the page will change to the li's inner text-->
<!-- */-->
<!-- $(".bg-colors li").dblclick(function (e){-->
<!-- const color = $(e.target).text();-->
<!-- $(this).css("color", color)-->
<!-- })-->
<!--</script>-->
<!--</body>-->
<!--</html>-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM Review</title>
<style>
</style>
</head>
<body>
<div id="set-one-container">
<h2>List Item Selected: <span class="show-list-item-text"></span></h2>
<ul class="data-example-container">
<li class="data-example" data-value="1">One</li>
<li class="data-example" data-value="2">Two</li>
<li class="data-example" data-value="3">Three</li>
<li class="data-example" data-value="4">Four</li>
</ul>
<h2>Attribute Value: <span id="show-data-attr"></span></h2>
<h2>List Item Selected: <span class="show-list-item-text"></span></h2>
</div>
<hr/>
<div id="set-two-container">
<div id="hover-container">
<h2>Child 1</h2>
<h2>Child 2</h2>
<h2>Child 3</h2>
<p>Child 4</p>
<div>
Child 5
<p>
Child... 6?
</p>
</div>
</div>
</div>
<hr/>
<div id="set-three-container">
<ul>
<li class="background-color-change">pick me!</li>
<li class="background-color-change">pick me!</li>
<li class="background-color-change">pick me!</li>
<li class="background-color-change">pick me!</li>
<li class="background-color-change">pick me!</li>
</ul>
</div>
<hr/>
<div id="set-four-container">
<input id="input">
<button id="concat-string">Concat</button>
<h3 id="output">Concat String:</h3>
</div>
<hr/>
<script src="js/jquery-3.5.1.js"></script>
<script src="js/dom-review.js"></script>
</body>
</html>