-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (37 loc) · 1.11 KB
/
script.js
File metadata and controls
45 lines (37 loc) · 1.11 KB
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
36
37
38
39
40
41
42
43
44
45
const form = document.getElementById('todo-form');
const input = document.getElementById('todo-input');
const todoList = document.getElementById('todo-list');
// Event listener for form submission
form.addEventListener('submit', function(event) {
event.preventDefault();
const task = input.value.trim();
if (task !== '') {
addTask(task);
input.value = '';
}
});
// Function to add a new task
function addTask(task) {
const li = document.createElement('li');
li.innerHTML = `
<input type="checkbox">
<span>${task}</span>
<button>Delete</button>
`;
todoList.appendChild(li);
// Event listener for delete button
const deleteButton = li.querySelector('button');
deleteButton.addEventListener('click', function() {
li.remove();
});
}
// Get the current date
const currentDate = new Date();
// Format the date as desired (e.g., "June 5, 2023")
const formattedDate = currentDate.toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric'
});
// Set the formatted date to the footer element
document.getElementById('current-date').textContent = formattedDate;