-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a491b05
commit 2036c63
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>To-Do List</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>To-Do List</h1> | ||
<div class="add-task"> | ||
<input type="text" id="taskInput" placeholder="Enter your task"> | ||
<button onclick="addTask()">Add</button> | ||
</div> | ||
<ul id="taskList"></ul> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function addTask() { | ||
const input = document.getElementById("taskInput"); | ||
const taskText = input.value.trim(); | ||
|
||
if (taskText !== "") { | ||
const taskList = document.getElementById("taskList"); | ||
const li = document.createElement("li"); | ||
li.innerHTML = ` | ||
<input type="checkbox" onchange="toggleTask(this)"> | ||
<span>${taskText}</span> | ||
<button onclick="deleteTask(this)">Delete</button> | ||
`; | ||
taskList.appendChild(li); | ||
input.value = ""; | ||
} | ||
} | ||
|
||
function toggleTask(checkbox) { | ||
const taskText = checkbox.nextElementSibling; | ||
if (checkbox.checked) { | ||
taskText.classList.add("completed"); | ||
} else { | ||
taskText.classList.remove("completed"); | ||
} | ||
} | ||
|
||
function deleteTask(button) { | ||
const li = button.parentElement; | ||
li.remove(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.container { | ||
max-width: 600px; | ||
margin: 20px auto; | ||
padding: 20px; | ||
border: 1px solid #ccc; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
border-radius: 5px; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
} | ||
|
||
.add-task { | ||
display: flex; | ||
gap: 10px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.add-task input { | ||
flex: 1; | ||
padding: 5px; | ||
} | ||
|
||
.add-task button { | ||
padding: 5px 10px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
li { | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.completed { | ||
text-decoration: line-through; | ||
} |