File tree 4 files changed +53
-1
lines changed
dom-and-events/exercises-CT 4 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 9
9
body {
10
10
background-color : yellow;
11
11
}
12
-
12
+
13
13
h1 {
14
14
font-size : 36px ;
15
15
/* text-align: center; */
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < title > Flight Simulator</ title >
5
+ < link rel ="stylesheet " type ="text/css " href ="style.css "/>
6
+ < script src = "script.js "> </ script >
7
+ </ head >
8
+ < body >
9
+ < h1 > Flight Simulator</ h1 >
10
+ < p id ="statusReport "> The shuttle is on the ground</ p >
11
+ < button id = "liftoffButton "> Take off</ button >
12
+ < button id = "abortMission "> Abort mission</ button >
13
+ </ body >
14
+ </ html >
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
+ button . addEventListener ( "click" , function ( event ) {
9
+ paragraph . innerHTML = "Houston, we have liftoff!" ;
10
+ // console.log(paragraph);
11
+ } ) ;
12
+
13
+ missionAbort . addEventListener ( "mouseover" , function ( event ) {
14
+ missionAbort . style . backgroundColor = "red" ;
15
+ console . log ( "Click to ABORT MISSION!" ) ;
16
+
17
+ } ) ;
18
+
19
+ missionAbort . addEventListener ( "mouseout" , function ( event ) {
20
+ missionAbort . style . backgroundColor = "" ;
21
+ } ) ;
22
+
23
+ missionAbort . addEventListener ( "click" , function ( event ) {
24
+ let response = window . confirm ( "Are you sure you want to abort the mission?" ) ;
25
+
26
+ if ( response ) {
27
+ paragraph . innerHTML = "Mission aborted! Space shuttle returning home" ;
28
+ } else {
29
+ paragraph . innerHTML = "Mission is NOT aborted! Space shuttle en route!" ;
30
+ }
31
+ } ) ;
32
+
33
+ }
34
+
35
+ window . addEventListener ( "load" , init ) ;
Original file line number Diff line number Diff line change
1
+ h1 {
2
+ text-decoration : underline;
3
+ }
You can’t perform that action at this time.
0 commit comments