Skip to content

Commit 47de257

Browse files
committed
DOM and Events exercises
1 parent bc7f1b6 commit 47de257

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

dom-and-events/exercises/script.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@ function init () {
44
const paragraph = document.getElementById("statusReport");
55

66
// Put your code for the exercises here.
7+
8+
button.addEventListener("click", function() {
9+
paragraph.innerHTML = "Houston, we have liftoff!";
10+
});
11+
12+
missionAbort.addEventListener("mouseover", event => {
13+
missionAbort.style.backgroundColor = "red"; //? why does it change the border radius and type?
14+
});
715

16+
missionAbort.addEventListener("mouseout", event => {
17+
event.target.style.backgroundColor = ""; //? is it better to use event with event.target? maybe for code resuseability?
18+
});
19+
20+
missionAbort.addEventListener("click", event => {
21+
let confirmed = window.confirm("Are you sure you want to abort the mission?");
22+
if (confirmed) {
23+
paragraph.innerHTML = "Mission aborted! Space shuttle returning home";
24+
}
25+
});
826
}
927

1028
window.addEventListener("load", init);

0 commit comments

Comments
 (0)