Skip to content

Commit b23d26c

Browse files
Dom and events exercises
1 parent 4bb5a84 commit b23d26c

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

dom-and-events/exercises/script.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
function init () {
1+
function init() {
22
const missionAbort = document.getElementById("abortMission");
33
const button = document.getElementById("liftoffButton");
44
const paragraph = document.getElementById("statusReport");
55

66
// Put your code for the exercises here.
7-
7+
button.addEventListener('click', event => {
8+
paragraph.innerHTML = 'Houston! We have liftoff!';
9+
});
10+
11+
missionAbort.addEventListener('mouseover', function( event ) {
12+
event.target.style.backgroundColor = "red";
13+
});
14+
15+
missionAbort.addEventListener('mouseout', function( event ) {
16+
event.target.style.backgroundColor = "";
17+
});
18+
19+
missionAbort.addEventListener('click', event => {
20+
window.confirm("Are you sure you want to abort the mission?")
21+
if(true){
22+
paragraph.innerHTML = 'Mission aborted! Space shuttle returning home.';
23+
}
24+
})
825
}
926

10-
window.addEventListener("load", init);
27+
window.addEventListener('load', init);

dom-and-events/exercises/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
body {
2+
background-color: rgb(179, 226, 183);
3+
}
4+
15
h1 {
26
text-decoration: underline;
37
}
8+
9+

0 commit comments

Comments
 (0)