My To-Do List
Description of the Code:
This is a To-Do List application built using HTML, CSS, and JavaScript. The tool allows users to:
- Add Tasks: Users can add tasks by typing them into a multi-line text box and clicking the "Add Task" button.
- Mark Tasks as Complete: A "Check" button lets users mark tasks as completed. Completed tasks are displayed with a strikethrough and reduced opacity.
- Delete Tasks: A "Delete" button next to each task allows users to remove that task from the list.
- Download Tasks: Each task can be downloaded as an individual text file by clicking the "Download" button beside each task. Additionally, all tasks can be downloaded at once using the "Download All Tasks" button.
Features:
- Add Task: Users can type a task and click "Add Task" to create a new task in the list. If the input field is empty, no task is added.
- Multi-line Textbox: The input field is a
textarea, allowing users to add multi-line tasks. The "Enter" key adds a new line in the text area, while the task is only added when clicking the "Add Task" button. - Task Marking: Clicking the "Check" button will toggle a strikethrough effect, marking the task as complete.
- Task Deletion: Clicking the "Delete" button removes the task from the list.
- Download Tasks:
- Each task can be downloaded separately by clicking the "Download" button.
- A "Download All Tasks" button allows users to download all tasks as separate
.txtfiles.
Use of the Code:
This To-Do List tool can be used in various scenarios where task management is needed, for example:
- Personal Task Management: Individuals can keep track of their personal to-dos and download tasks for later reference or backup.
- Project Management: For managing a team or project tasks, users can add tasks, mark them as completed, and download or share them.
- Educational Use: Students or teachers can use the list for assignments and tasks, marking them off as they are completed.
- Daily Planning: Users can add daily tasks, track progress, and download the list at the end of the day for record-keeping.
Key Components:
HTML:
- Structure of the page, including the input field, buttons, and task list.
- Uses a
textareafor multi-line input and a list (ul) to display tasks.
CSS:
- Provides the visual design for the To-Do List.
- Includes responsive styling to ensure the layout adapts to different screen sizes (mobile and desktop).
- Uses hover effects and smooth transitions for a better user experience.
JavaScript:
- Handles the logic behind adding, marking as completed, deleting, and downloading tasks.
- Listens for events like clicking the "Add Task" button and pressing "Enter" in the input field.
- Handles the download functionality, creating individual
.txtfiles for tasks.
How to Use:
Adding a Task:
- Type your task in the
textareafield. - Press "Add Task" to add the task to your to-do list.
- Type your task in the
Marking a Task as Complete:
- Click the checkmark (✔) button next to any task to mark it as completed. This will strike through the task.
Deleting a Task:
- Click the delete (❌) button next to any task to remove it from the list.
Downloading a Task:
- Click the Download button next to each task to download it as a
.txtfile.
- Click the Download button next to each task to download it as a
Downloading All Tasks:
- Click the Download All Tasks button to download each task as a separate
.txtfile.
- Click the Download All Tasks button to download each task as a separate
How the Code Works:
Adding a Task: When the user clicks the "Add Task" button, the
createTask()function is called. It creates a new list item (li) for the task and appends it to theullist. Each task has a check button, delete button, and download button.Marking as Complete: When the user clicks the "Check" button, the task item gets a
completedclass, which adds a strikethrough effect via CSS and reduces the opacity.Deleting a Task: The "Delete" button removes the task from the DOM when clicked.
Downloading a Task: When the user clicks the "Download" button, the text of the task is extracted and saved as a
.txtfile. This is done by creating aBlobwith the task content and triggering a download link.Downloading All Tasks: The "Download All Tasks" button loops through all tasks and downloads each task as a separate
.txtfile.
You can further enhance this tool by:
- Adding the ability to edit tasks.
- Storing tasks in the browser’s local storage to persist data even after the page is refreshed.
- Adding categories or priorities for tasks.

.png)