Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulhai123456789 committed Jun 5, 2024
0 parents commit ec93ad4
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('todo-form');
const todoInput = document.getElementById('new-todo');
const todoList = document.getElementById('todo-list');

form.addEventListener('submit', (e) => {
e.preventDefault();
const newTodoText = todoInput.value.trim();
if (newTodoText !== '') {
addTodoItem(newTodoText);
todoInput.value = '';
}
});

function addTodoItem(text) {
const li = document.createElement('li');
li.textContent = text;
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', () => {
todoList.removeChild(li);
});
li.appendChild(deleteButton);
todoList.appendChild(li);
}
});
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="style.css">
</head>
<body>
<div class="container">
<h1>To-Do List</h1>
<form id="todo-form">
<input type="text" id="new-todo" placeholder="Add a new to-do" required>
<button type="submit">Add</button>
</form>
<ul id="todo-list"></ul>
</div>
<script src="app.js"></script>
</body>
</html>
71 changes: 71 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}

.container {
width: 300px;
margin: 50px auto;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
}

form {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}

input {
width: 70%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}

button {
padding: 10px;
border: none;
border-radius: 5px;
background-color: #333;
color: white;
cursor: pointer;
}

button:hover {
background-color: #555;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: flex;
justify-content: space-between;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 10px;
}

li button {
border: none;
background-color: red;
color: white;
border-radius: 5px;
cursor: pointer;
}

li button:hover {
background-color: darkred;
}

0 comments on commit ec93ad4

Please sign in to comment.