Skip to content

Commit 6ed9684

Browse files
committed
feat: change colour of link if clicked
1 parent 5663c8c commit 6ed9684

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h2 class="section-left-subtitle">Advanced</h2>
5252
<li id="polymorphism">Polymorphism</li>
5353
</ul>
5454
</section>
55-
<section class="section-right">A refresher on Javascript concepts in less than 30 words. This is an open source project. Contributions are welcome via <a target ="_blank" href="https://github.com/msmfa/javascript-in-30">Github</a></section>
55+
<section class="section-right">A refresher on Javascript concepts in less than 30 words. This is an open source project. Contributions are welcome via <a target ="_blank" href="https://github.com/msmfa/javascript-in-30">Github.</a></section>
5656
</main>
5757
<script type="module" src="main.js"></script>
5858
</body>

src/main.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ul li {
2424
}
2525

2626
a {
27-
color: rgb(240, 158, 8);
27+
color: #f09e3f;
2828
text-decoration: none;
2929
}
3030

@@ -49,7 +49,6 @@ a {
4949
}
5050

5151
.section-left li:hover {
52-
color: rgb(101, 180, 226);
5352
cursor: pointer;
5453
}
5554

src/main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ sectionLeft.addEventListener("click", function (e) {
3434

3535
const { image: imageUrl, text, bulletPointItems } = selectedDefinition;
3636

37+
// When the user clicks on a list element set it's color to orange
38+
// and set the rest to black
39+
document.querySelectorAll(".section-left li").forEach((element) => {
40+
if (element.id === selectedValue) {
41+
element.style.color = "#F09E3F";
42+
} else {
43+
element.style.color = "black";
44+
}
45+
});
46+
3747
renderHTML(
3848
sectionRight,
3949
text,

0 commit comments

Comments
 (0)