-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlesson-5.html
More file actions
56 lines (50 loc) · 1.76 KB
/
lesson-5.html
File metadata and controls
56 lines (50 loc) · 1.76 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
<html>
<head>
<!--We're importing some of the generic styles from the last lesson.-->
<link rel="stylesheet"
href="./style.css">
</link>
</head>
<body>
<a href="./index.html">Home</a>
<h1>Lesson 5 - Editing HTML with JavaScript</h1>
<div class="dotted-div">
<h2>Task 1: Finding Elements on the page using JavaScript</h2>
<div class="info">You can find an element on the page using JavaScript, using code that looks like this:
<code>document.querySelector("#my-element-name")</code>. This allows you to edit your HTML page with JavaScript.
</div>
<p>Update <code>document.querySelector("#I-CANT-FIND-MY-ELEMENT")</code> to instead look for an element with the id
of
<code>#update-text</code>. When you refresh the page, the new JavaScript text should overwrite the original HTML
message.
</p>
<p><strong>Bonus:</strong> Update the JavaScript message to say something new, like "Hello!"</p>
<strong id="update-text">
This is the original HTML text. If you can still see it, it means you haven't found the
element successfully in JavaScript :(</strong>
</div>
<div class="key-takeaways">
<h2>Key Takeaways</h2>
<ul>
<li>
I can edit the <code>document.querySelector</code> in JavaScript to successfully find an element.
</li>
<li>
I can insert custom text into HTML using JavaScript.
</li>
</ul>
</div>
<a href="./lesson-4.html">
Previous Lesson
</a>
|
<a href="./lesson-6.html">
Next Lesson
</a>
</body>
</html>
<script>
/*** TASK 1 ***/
//TODO: Update "#I-CANT-FIND-MY-ELEMENT" to be the name of the element you want to update.
document.querySelector("#I-CANT-FIND-MY-ELEMENT").innerHTML = "This text was set with JavaScript!";
</script>