Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
warrior75069 authored Oct 28, 2023
1 parent a491b05 commit 2036c63
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.html
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>
30 changes: 30 additions & 0 deletions script.js
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();
}
54 changes: 54 additions & 0 deletions styles.css
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;
}

0 comments on commit 2036c63

Please sign in to comment.