Skip to main content

Building a Simple To-Do List Web App with HTML, CSS, and JavaScript

Title: Building a Simple To-Do List Web App with HTML, CSS, and JavaScript



See the Pen Building a Simple To-Do List Web App with HTML, CSS, and JavaScript by AryCodes (@AryCodes) on CodePen.

Introduction:

In this blog post, we'll take you through the step-by-step process of creating a basic to-do list web application using HTML, CSS, and JavaScript. By the end of this tutorial, you'll have a fully functional to-do list that you can use to keep track of tasks and mark them as completed.

HTML Structure:

Let's start by setting up the HTML structure for our to-do list. We'll create a basic template that includes the necessary elements for our application.

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Meta and title tags -->
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <div class="todolist" id="todolist">
            <!-- Tasks will be added here dynamically -->
        </div>
        <div class="addtaskcontainer">
            <input type="text" id="inputtask" placeholder="Add a task">
            <button id="addtask">Add</button>
        </div>
    </div>
    <script src="script.js"></script>
</body>
</html>
```

CSS Styling:

We've used CSS to style our to-do list application. The styling includes background images, rounded corners, and customized scrollbars to make the app visually appealing.

```css
/* CSS styles go here */
```

JavaScript Functionality:

The JavaScript code is responsible for the core functionality of our to-do list. It listens for the "Add" button click, creates new tasks, and manages task completion using checkboxes.

```javascript
let submitbutton = document.getElementById("addtask");

submitbutton.addEventListener("click", () => {
    var newtask = document.getElementById("inputtask").value;
    task = newtask.trim()
    if (newtask != "") {
        var list = document.getElementById("todolist")
        var taskElement = document.createElement("span");
        taskElement.className = "tasks";
        taskElement.id = "tasks";
        taskElement.innerHTML = `<input type="checkbox" id="check"><p id="task">${newtask}</p>`;
        list.appendChild(taskElement);
        document.getElementById("inputtask").value = "";
        toaddeventlistener()
    }
})

function toaddeventlistener() {
    document.querySelectorAll("#check").forEach(element => {
        element.addEventListener("click", () => {
            var tasks = document.querySelectorAll(".tasks");
            tasks.forEach(task => {
                var checkbox = task.querySelector("#check");
                if (checkbox.checked) {
                    var p = task.querySelector("#task");
                    p.style.textDecoration = "line-through";
                } else {
                    var p = task.querySelector("#task");
                    p.style.textDecoration = "none";
                }
            });
        })
    });
}

toaddeventlistener()
```

Conclusion:

In this tutorial, we've walked you through the process of creating a simple to-do list web application using HTML, CSS, and JavaScript. You can use this project as a starting point and build upon it to create more advanced to-do list applications with additional features. Have fun coding and enhancing your to-do list application!

Author: AryCodes


Comments

Popular posts from this blog

Creating a Festive Snowfall Effect For Christmas with HTML, CSS, and JavaScript

Creating a Festive Snowfall Effect For Christmas with HTML, CSS, and JavaScript Introduction: 'Tis the season to bring joy and festivity to your website! In this blog post, we'll walk through the process of creating a delightful snowfall effect using HTML, CSS, and JavaScript. By combining particle.js, anime.js, and some creative styling, we'll add a touch of magic to your web page. See the Pen Untitled by AryCodes ( @AryCodes ) on CodePen .  Setting the Stage To start, let's create the basic structure of our webpage. We have an HTML document with a red background, a Google Font for a stylish greeting, and a background image to enhance the festive atmosphere. The cursor is set to a crosshair, adding an interactive feel. ```html <!DOCTYPE html> <html lang="en"> <head>     <!-- meta tags, stylesheets, and script references --> </head> <body>     <!-- Particle animation container -->     <div id=...

Building a Fun Rating Page: A Step-by-Step Guide

Building a Fun Rating Page: A Step-by-Step Guide Hey there! Ready to create a cool rating page for your website? Let's make it simple and fun using HTML, CSS, and JavaScript. This step-by-step guide will help you create a visually appealing page where users can rate their experience with cute stars and emojis. See the Pen Untitled by AryCodes ( @AryCodes ) on CodePen . Step 1: Setting Up the Basics Start with the basic structure of your HTML file. Include the title, link to your style sheet, and the main content container. ```html <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Rating Page</title>     <link rel="stylesheet" href="styles.css"> </head> <body>     <div class="rating-container">         <!-- Content ...

Getting Started with Programming

Programming , we can say language of the future , is a skill that has become most valuable in todays digital era . Whether you are interested in building website or developing mobile app , or dive into the data analysis , learn to code can open up a world of opportunities for you but where should you start , in this blog we are talking about the basis of programming and provide you the resources to start your journey Why Learning Programming ? before we are getting started lets know why programming and why this skill is worthy 1. High Demanding : with the rise in technology there is a growing demand of skilled programmers and developers across various industries whether it is tech of business related. 2. Problem Solving skills: Programming teaches you how to break down complex problems into slow one and solve that effortlessly and more manageable way. 3. Creativity : Coding and programing help you  to solve real world problems that you see around you and provide you to solve them ...