32 lines
1.2 KiB
JavaScript
Executable File
32 lines
1.2 KiB
JavaScript
Executable File
(function () {
|
|
const modePrint = document.querySelector("#mode-print");
|
|
modePrint.addEventListener("click", () => window.print());
|
|
|
|
const themeStealth = document.querySelector("#theme-stealth");
|
|
const header = document.querySelector("body > header > h1");
|
|
const body = document.querySelector("body");
|
|
themeStealth.addEventListener("click", () => {
|
|
body.classList.toggle("stealth");
|
|
if (body.classList.contains("stealth")) {
|
|
header.innerText += "(Stealth Mode)";
|
|
} else {
|
|
header.innerText = "Header";
|
|
}
|
|
});
|
|
|
|
const articleH3s = document.querySelectorAll("article > h3");
|
|
articleH3s.forEach((element) => {
|
|
element.addEventListener("click", (event) => {
|
|
event.target.nextElementSibling.hidden =
|
|
!event.target.nextElementSibling.hidden;
|
|
});
|
|
});
|
|
/* TODO: Add a click event listener to the article h3 titles. When
|
|
* clicked, make the text of the associated p element hidden. HINT:
|
|
* event listener callback functions receive an event parameter
|
|
* object. event.target will refer to the object clicked (i.e., the
|
|
* h3 title). If you print that element out to the console, you can
|
|
* examine its fields to find how to access the p element that
|
|
* follows. */
|
|
})();
|