Skip to content

Commit a32b2be

Browse files
Assignment complete
1 parent bb96b7e commit a32b2be

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

dom-and-events/exercises/script.js

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

66
// Put your code for the exercises here.
7-
}
8-
97
button.addEventListener('click', event => {
10-
paragraph.innerHTML = 'Houston! We have liftoff!';
11-
});
12-
8+
paragraph.innerHTML = 'Houston! We have lift off!';
9+
});
10+
1311
missionAbort.addEventListener("mouseout", function( event ) {
14-
event.target.style.backgroundColor = "";
15-
});
12+
event.target.style.backgroundColor = "";
13+
});
14+
}
15+
document.addEventListener('DOMContentLoaded', function() {
16+
const abortButton = document.getElementById('abortMission');
17+
18+
abortButton.addEventListener('click', function() {
19+
// Show confirmation dialog
20+
const confirmAbort = confirm('Are you sure you want to abort the mission?');
21+
22+
if (confirmAbort) {
23+
// User confirmed, change the button text
24+
abortButton.textContent = 'Mission aborted! Space shuttle returning home.';
25+
26+
// Optionally, disable the button after aborting
27+
abortButton.disabled = true;
28+
29+
// Optionally, change the button's appearance to indicate aborted state
30+
abortButton.style.backgroundColor = 'gray';
31+
abortButton.style.color = 'white';
32+
}
33+
// If user cancels, do nothing and the button remains unchanged
34+
});
35+
});
1636

17-
window.addEventListener("load", init);
37+
window.addEventListener("load", init);

dom-and-events/exercises/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
h1 {
22
text-decoration: underline;
33
}
4+
#abortMission {
5+
padding: 10px 20px;
6+
font-size: 16px;
7+
cursor: pointer;
8+
background-color: #f0f0f0;
9+
border: 1px solid #ccc;
10+
transition: background-color 0.3s ease;
11+
}
12+
13+
#abortMission:hover {
14+
background-color: red;
15+
color: white;
16+
}

0 commit comments

Comments
 (0)