File tree 1 file changed +29
-8
lines changed
1 file changed +29
-8
lines changed Original file line number Diff line number Diff line change 1
- function init ( ) {
2
- const missionAbort = document . getElementById ( "abortMission" ) ;
3
- const button = document . getElementById ( "liftoffButton" ) ;
4
- const paragraph = document . getElementById ( "statusReport" ) ;
5
-
6
- // Put your code for the exercises here.
7
-
8
- }
1
+ function init ( ) {
2
+ const missionAbort = document . getElementById ( "abortMission" ) ;
3
+ const button = document . getElementById ( "liftoffButton" ) ;
4
+ const paragraph = document . getElementById ( "statusReport" ) ;
5
+
6
+ // Put your code for the exercises here.
7
+ button . addEventListener ( "click" , function ( ) {
8
+ paragraph . innerHTML = "Houston, we have liftoff!" ;
9
+ } ) ;
10
+
11
+ missionAbort . addEventListener ( "mouseover" , function ( event ) {
12
+ const element = event . target ;
13
+ element . style . backgroundColor = "red" ;
14
+ } ) ;
15
+
16
+ missionAbort . addEventListener ( "mouseout" , function ( event ) {
17
+ event . target . style . backgroundColor = "" ;
18
+ } ) ;
19
+
20
+ missionAbort . addEventListener ( "click" , function ( ) {
21
+ const 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
+ } else {
25
+ paragraph . innerHTML = "Mission continues. Stay on course!" ;
26
+ }
27
+ } ) ;
28
+
29
+ } ;
9
30
10
31
window . addEventListener ( "load" , init ) ;
You can’t perform that action at this time.
0 commit comments