forked from ossamamehmood/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskmanage.html
42 lines (37 loc) · 1.14 KB
/
taskmanage.html
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
<!DOCTYPE html>
<html>
<head>
<title>Task Manager</title>
</head>
<body>
<h1>Task Manager</h1>
<input type="text" id="taskInput" placeholder="Enter a task">
<button onclick="addTask()">Add Task</button>
<ul id="taskList"></ul>
<script>
// Array to store tasks
const tasks = [];
// Function to add a new task
function addTask() {
const taskInput = document.getElementById('taskInput');
const taskText = taskInput.value.trim();
if (taskText) {
tasks.push(taskText);
taskInput.value = '';
displayTasks();
}
}
// Function to display tasks
function displayTasks() {
const taskList = document.getElementById('taskList');
taskList.innerHTML = '';
for (let i = 0; i < tasks.length; i++) {
const li = document.createElement('li');
li.textContent = tasks[i];
taskList.appendChild(li);
}
}
// Initialize the application
function init() {
displayTasks();
}