File tree 3 files changed +139
-0
lines changed
3 files changed +139
-0
lines changed 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 > Task List</ title >
7
+ < link rel ="stylesheet " href ="./main.css ">
8
+ </ head >
9
+ < body >
10
+ < div class ="container ">
11
+ < header >
12
+ < h1 > Task List</ h1 >
13
+ </ header >
14
+ < form action ="">
15
+ < input id ="task-name " type ="text " placeholder ="Task name ">
16
+ < button id ="btn-add " type ="submit "> Add</ button >
17
+ </ form >
18
+ < ul id ="tasks ">
19
+ < li id ="new-task "> </ li >
20
+ </ ul >
21
+ </ div >
22
+ < script src ="https://code.jquery.com/jquery-3.7.1.min.js "> </ script >
23
+ < script src ="./main.js "> </ script >
24
+ </ body >
25
+ </ html >
Original file line number Diff line number Diff line change
1
+ * {
2
+ padding : 0 ;
3
+ margin : 0 ;
4
+ box-sizing : border-box;
5
+ font-weight : bold;
6
+ font-family : Verdana, Geneva, Tahoma, sans-serif;
7
+ }
8
+
9
+
10
+ body {
11
+ max-width : 600px ;
12
+ width : 500px ;
13
+ margin : 100px auto;
14
+
15
+ }
16
+
17
+ .container {
18
+ width : 100% ;
19
+ background-color : rgb (191 , 227 , 243 );
20
+ padding : 16px ;
21
+ border : 10px solid rgb (153 , 216 , 243 );
22
+ }
23
+
24
+ header {
25
+ text-align : center;
26
+ margin-bottom : 16px ;
27
+ }
28
+
29
+ form {
30
+ margin-bottom : 32px ;
31
+ }
32
+
33
+ form h1 {
34
+ margin-right : 16px ;
35
+ }
36
+
37
+ form , ul {
38
+ display : flex;
39
+ align-items : center;
40
+ justify-content : center;
41
+ }
42
+
43
+ form input {
44
+ font-weight : normal;
45
+ }
46
+
47
+
48
+ form button ,
49
+ form input {
50
+ cursor : pointer;
51
+ border : none;
52
+ padding : 8px ;
53
+ border-bottom : 1px solid black;
54
+ }
55
+
56
+
57
+ ul li {
58
+ list-style : none;
59
+ cursor : pointer;
60
+ margin-bottom : 16px ;
61
+ }
62
+
63
+ .task-completed {
64
+ text-decoration : line-through 2px ;
65
+ color : green;
66
+ }
67
+
68
+
69
+
Original file line number Diff line number Diff line change
1
+ $ ( document ) . ready ( function ( ) {
2
+
3
+ const tasks = [ ] ;
4
+ const taskCompleted = $ ( '<li class = "task-completed"></li>' ) ;
5
+ const taskNameInput = $ ( '#task-name' ) ;
6
+
7
+
8
+ let lines = '' ;
9
+
10
+ $ ( 'form' ) . on ( 'submit' , function ( e ) {
11
+ e . preventDefault ( ) ;
12
+ addLine ( ) ;
13
+
14
+
15
+
16
+ } )
17
+
18
+ function addLine ( ) {
19
+
20
+
21
+ if ( tasks . includes ( taskNameInput . val ( ) ) ) {
22
+ alert ( `Task already added!` ) ;
23
+ taskNameInput . val ( '' ) ;
24
+
25
+ } else {
26
+ tasks . push ( taskNameInput . val ( ) ) ;
27
+
28
+ const taskItem = $ ( `
29
+ <ul>
30
+ <li>${ taskNameInput . val ( ) } </li>
31
+ </ul>
32
+ ` ) . appendTo ( '#new-task' ) ;
33
+
34
+ taskItem . find ( 'li' ) . click ( function ( ) {
35
+ $ ( this ) . toggleClass ( 'task-completed' ) ;
36
+ } ) ;
37
+
38
+ taskNameInput . val ( '' ) ;
39
+
40
+
41
+ }
42
+ }
43
+
44
+
45
+ } )
You can’t perform that action at this time.
0 commit comments