@@ -4,14 +4,34 @@ function init () {
4
4
const paragraph = document . getElementById ( "statusReport" ) ;
5
5
6
6
// Put your code for the exercises here.
7
- }
8
-
9
7
button . addEventListener ( 'click' , event => {
10
- paragraph . innerHTML = 'Houston! We have liftoff !' ;
11
- } ) ;
12
-
8
+ paragraph . innerHTML = 'Houston! We have lift off !' ;
9
+ } ) ;
10
+
13
11
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
+ } ) ;
16
36
17
- window . addEventListener ( "load" , init ) ;
37
+ window . addEventListener ( "load" , init ) ;
0 commit comments