File tree Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Expand file tree Collapse file tree 3 files changed +101
-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 > Simple To-Do List</ title >
7+ < link rel ="stylesheet " href ="styles.css ">
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < h1 > To-Do List</ h1 >
12+ < input type ="text " id ="taskInput " placeholder ="Add a new task... ">
13+ < button id ="addTaskButton "> Add Task</ button >
14+ < ul id ="taskList "> </ ul >
15+ </ div >
16+ < script src ="script.js "> </ script >
17+ </ body >
18+ </ html >
Original file line number Diff line number Diff line change 1+ document . getElementById ( "addTaskButton" ) . addEventListener ( "click" , function ( ) {
2+ const taskInput = document . getElementById ( "taskInput" ) ;
3+ const taskValue = taskInput . value . trim ( ) ;
4+
5+ if ( taskValue ) {
6+ const li = document . createElement ( "li" ) ;
7+ li . textContent = taskValue ;
8+
9+ const deleteButton = document . createElement ( "button" ) ;
10+ deleteButton . textContent = "Delete" ;
11+ deleteButton . onclick = function ( ) {
12+ li . remove ( ) ;
13+ } ;
14+
15+ li . appendChild ( deleteButton ) ;
16+ document . getElementById ( "taskList" ) . appendChild ( li ) ;
17+ taskInput . value = "" ;
18+ }
19+ } ) ;
Original file line number Diff line number Diff line change 1+ body {
2+ font-family : Arial, sans-serif;
3+ background-color : # f4f4f4 ;
4+ margin : 0 ;
5+ padding : 20px ;
6+ }
7+
8+ .container {
9+ max-width : 400px ;
10+ margin : auto;
11+ background : white;
12+ padding : 20px ;
13+ border-radius : 5px ;
14+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.1 );
15+ }
16+
17+ h1 {
18+ text-align : center;
19+ }
20+
21+ input [type = "text" ] {
22+ width : calc (100% - 90px );
23+ padding : 10px ;
24+ border : 1px solid # ccc ;
25+ border-radius : 5px ;
26+ }
27+
28+ button {
29+ padding : 10px ;
30+ border : none;
31+ background : # 28a745 ;
32+ color : white;
33+ border-radius : 5px ;
34+ cursor : pointer;
35+ }
36+
37+ button : hover {
38+ background : # 218838 ;
39+ }
40+
41+ ul {
42+ list-style-type : none;
43+ padding : 0 ;
44+ }
45+
46+ li {
47+ padding : 10px ;
48+ border-bottom : 1px solid # ccc ;
49+ display : flex;
50+ justify-content : space-between;
51+ align-items : center;
52+ }
53+
54+ li button {
55+ background : # dc3545 ;
56+ border : none;
57+ color : white;
58+ border-radius : 5px ;
59+ cursor : pointer;
60+ }
61+
62+ li button : hover {
63+ background : # c82333 ;
64+ }
You can’t perform that action at this time.
0 commit comments