File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Practice Event in Js</ title >
7+ < link rel ="stylesheet " href ="style.css "/>
8+ </ head >
9+
10+
11+
12+ < body >
13+
14+ < div class ="login-container ">
15+ < h2 > Login</ h2 >
16+ < form id ="loginForm ">
17+ < div class ="input-group ">
18+ < label for ="username "> Username:</ label >
19+ < input type ="text " id ="username " name ="username " required >
20+ </ div >
21+ < div class ="input-group ">
22+ < label for ="password "> Password:</ label >
23+ < input type ="password " id ="password " name ="password " required >
24+ </ div >
25+ < button type ="submit "> Login</ button >
26+ < button id ="mode "> Change Mode</ button >
27+ </ form >
28+ < p id ="loginMessage "> </ p >
29+ </ div >
30+
31+
32+
33+ < script src ="practice.js "> </ script >
34+ </ body >
35+ </ html >
Original file line number Diff line number Diff line change 1+ let modeBtn = document . querySelector ( "#mode" ) ;
2+ let body = document . querySelector ( "body" ) ;
3+ let curmode = "light" //black
4+
5+ modeBtn . addEventListener ( "click" , ( ) => {
6+ if ( curmode === "light" ) {
7+ curmode = "dark" ;
8+ body . classList . add ( "dark" ) ;
9+ body . classList . remove ( "light" ) ;
10+ } else {
11+ curmode = "light" ;
12+ body . classList . add ( "light" ) ;
13+ body . classList . remove ( "dark" ) ;
14+ }
15+ console . log ( curmode ) ;
16+
17+ } )
18+
19+
Original file line number Diff line number Diff line change 1+ .dark {
2+ background-color : black;
3+ color : white;
4+ }
5+
6+
7+ .light {
8+ background-color : white;
9+ color : black;
10+ }
11+
12+ body {
13+ display : flex;
14+ justify-content : center;
15+ align-items : center;
16+ height : 100vh ;
17+ margin : 0 ;
18+ }
19+
20+
21+ /* Style your login page here */
22+ .login-container {
23+ width : 300px ;
24+ margin : 50px auto;
25+ padding : 20px ;
26+ border : 1px solid # ccc ;
27+ border-radius : 5px ;
28+ }
29+
30+ .input-group {
31+ margin-bottom : 15px ;
32+ }
33+
34+ label {
35+ display : block;
36+ margin-bottom : 5px ;
37+ }
38+
39+ input [type = "text" ],
40+ input [type = "password" ] {
41+ width : calc (100% - 10px );
42+ padding : 5px ;
43+ }
44+
45+ button {
46+ padding : 8px 15px ;
47+ background-color : # 007bff ;
48+ color : white;
49+ border : none;
50+ border-radius : 4px ;
51+ cursor : pointer;
52+ }
53+
54+ button : hover {
55+ background-color : # 0056b3 ;
56+ }
57+
You can’t perform that action at this time.
0 commit comments