-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (29 loc) · 1.07 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.addEventListener("DOMContentLoaded", function () {
const taskForm = document.getElementById("taskForm");
const taskInput = document.getElementById("taskInput");
const reminderInput = document.getElementById("reminderInput");
const taskList = document.getElementById("taskList");
taskForm.addEventListener("submit", function (e) {
e.preventDefault();
addTask();
});
function addTask() {
const taskText = taskInput.value.trim();
const reminderDateTime = reminderInput.value.trim();
if (taskText === "") return;
const li = document.createElement("li");
li.innerHTML = `
<span>${taskText}</span>
<span>${reminderDateTime}</span>
<button class="delete-btn" onclick="deleteTask(this)">Delete</button>
`;
taskList.appendChild(li);
// Clear input fields
taskInput.value = "";
reminderInput.value = "";
}
window.deleteTask = function (element) {
const li = element.parentElement;
li.remove();
};
});