Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
JavaScript Hello World
Next article icon

JavaScript Course Task Tracker Project

Last Updated : 18 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this final article of this course, we will learn how to make a simple javascript application where we can add tasks, delete tasks and edit them too. Pure(Vanilla) JavaScript has been used and we will also make use of DOM manipulation a lot so one of the main prerequisites is HTML | DOM.

Project Structure:

index.html
styles.css
list.js

Project Preview:

Course Tracker Project

Example: In this example code, we have built the course tracker project using javascript.

HTML
<!DOCTYPE html> <html>  <head>     <title>Task Tracker</title>     <link rel="stylesheet" href="styles.css" type="text/css" media="screen" charset="utf-8">   </head>  <body>     <div class="container">         <p>             <label for="new-task" class="middle">Add Task</label>             <input id="new-task" type="text">             <button>Add Task</button>         </p>         <h3 class="middle">Todo</h3>         <ul id="incomplete-tasks">         </ul>         <h3 class="middle">Completed Tasks</h3>         <ul id="completed-tasks">         </ul>     </div>     <script type="text/javascript" src="list.js"></script>      </body>  </html> 
CSS
 /* Basic Style */     body {         background: #ecf0f1;         color: #333;         font-family: Lato, sans-serif;     }      .container {         display: block;         width: 500px;         margin: 50px auto 0;     }      ul {         margin: 0;         padding: 0;     }      li * {         float: left;     }      li,     h3 {         clear: both;         list-style: none;     }      input,     button {         outline: none;     }      button {         background: none;         border: 0;         color: #888;         font-size: 15px;         width: 100px;         margin: 10px 0 0;         font-family: Lato, sans-serif;         cursor: pointer;     }      button:hover {         color: #333;     }      /* Heading */     h3,     label[for='new-task'] {         color: #333;         font-weight: 700;         font-size: 15px;         border-bottom: 2px solid #333;         padding: 30px 0 10px;         margin: 0;         text-transform: uppercase;     }      input[type="text"] {         margin: 0;         font-size: 18px;         line-height: 18px;         height: 18px;         padding: 10px;         border: 1px solid #ddd;         background: #fff;         border-radius: 6px;         font-family: Lato, sans-serif;         color: #888;     }      input[type="text"]:focus {         color: #333;     }      .middle {         text-align: center;     }       /* New Task */     label[for='new-task'] {         display: block;         margin: 0 0 20px;     }      input#new-task {         float: right;         width: 318px;     }      p>button:hover {         color: #0FC57C;     }      /* Task list */     li {         overflow: hidden;         padding: 20px 0;         border-bottom: 1px solid #eee;     }      li>input[type="checkbox"] {         margin: 0 10px;         position: relative;         top: 15px;     }      li>label {         font-size: 18px;         line-height: 40px;         width: 237px;         padding: 0 0 0 11px;     }      li>input[type="text"] {         width: 226px;     }      li>.delete:hover {         color: #CF2323;     }      /* Completed */     #completed-tasks label {         text-decoration: line-through;         color: #888;     }      /* Edit Task */     ul li input[type=text] {         display: none;     }      ul li.editMode input[type=text] {         display: block;     }      ul li.editMode label {         display: none;     } 
JavaScript
  // Add a new task.     let taskInput = document.getElementById("new-task");      // first button     let addButton = document.getElementsByTagName("button")[0];      // ul of #incomplete-tasks     let incompleteTaskHolder = document.getElementById("incomplete-tasks");      // completed-tasks     let completedTasksHolder = document.getElementById("completed-tasks");      /*---- Part 1 ----*/     // function to create a new task item     let createNewTaskElement = function (taskString) {          let listItem = document.createElement("li");          // input (checkbox)         let checkBox = document.createElement("input");         // label         let label = document.createElement("label");         // input (text)         let editInput = document.createElement("input");         // button.edit         let editButton = document.createElement("button");          // button.delete         let deleteButton = document.createElement("button");          label.innerText = taskString;          // Each element needs appending         checkBox.type = "checkbox";         editInput.type = "text";           // innerText encodes special characters, HTML does not.         editButton.innerText = "Edit";         editButton.className = "edit";         deleteButton.innerText = "Delete";         deleteButton.className = "delete";          // Append elements         listItem.appendChild(checkBox);         listItem.appendChild(label);         listItem.appendChild(editInput);         listItem.appendChild(editButton);         listItem.appendChild(deleteButton);         return listItem;     }     /*---- Part 2 ----*/     let addTask = function () {          let listItem = createNewTaskElement(taskInput.value);          if (taskInput.value === "") {             return;         }          // Append listItem to incompleteTaskHolder         incompleteTaskHolder.appendChild(listItem);         bindTaskEvents(listItem, taskCompleted);          taskInput.value = "";      }      /*---- Part 3 ----*/     let editTask = function () {         let listItem = this.parentNode;          let editInput = listItem.querySelector('input[type=text]');         let label = listItem.querySelector("label");         let containsClass = listItem.classList.contains("editMode");         // If class of the parent is .editmode         if (containsClass) {             label.innerText = editInput.value;         } else {             editInput.value = label.innerText;         }         listItem.classList.toggle("editMode");     }      /*---- Part 4 ----*/     let deleteTask = function () {          let listItem = this.parentNode;         let ul = listItem.parentNode;         // Remove the parent list item from the ul.         ul.removeChild(listItem);      }      /*---- Part 5 ----*/      let taskCompleted = function () {          // Append the task list item to the #completed-tasks         let listItem = this.parentNode;         completedTasksHolder.appendChild(listItem);         bindTaskEvents(listItem, taskIncomplete);      }      /*---- Part 6 ----*/     let taskIncomplete = function () {         // Mark task as incomplete.         // When the checkbox is unchecked         // Append the task list item to the #incomplete-tasks.         let listItem = this.parentNode;         incompleteTaskHolder.appendChild(listItem);         bindTaskEvents(listItem, taskCompleted);      }      /*---- Part 7 ----*/     let bindTaskEvents = function (taskListItem, checkBoxEventHandler) {          // select taskListItem's children         let checkBox = taskListItem.querySelector("input[type=checkbox]");         let editButton = taskListItem.querySelector("button.edit");         let deleteButton = taskListItem.querySelector("button.delete");          // bind editTask to edit button         editButton.onclick = editTask;         // bind deleteTask to delete button         deleteButton.onclick = deleteTask;         // bind checkBoxEventHandler to checkbox         checkBox.onchange = checkBoxEventHandler;     }      /*---- Part 8 ----*/     // Set the click handler to the addTask function     addButton.addEventListener("click", addTask);     addButton.addEventListener("click", ajaxRequest);      /*---- Part 9 ----*/     // Cycle over incompleteTaskHolder ul list items     for (let i = 0; i < incompleteTaskHolder.children.length; i++) {         // bind events to list item's children (taskCompleted)         bindTaskEvents(incompleteTaskHolder.children[i], taskCompleted);     }      /*---- Part 10 ----*/     // Cycle over completedTasksHolder ul list items     for (let i = 0; i < completedTasksHolder.children.length; i++) {         // bind events to list item's children (taskIncomplete)         bindTaskEvents(completedTasksHolder.children[i], taskIncomplete);     } 

Output

JavaScript Course Task Tracker Project

JavaScript Course Task Tracker Project

Explanation: 

The above HTML code contains simple list tags and one text field which we will populate with text when we add, or delete tasks. Certain classes are assigned which we make use of while getting that particular element by DOM or by styling it inside the styles.css file. All the above content is inside a div with the class ‘container’ that has its own styling and attributes.

Explanation

Part 1: The way this function works is that it takes the ‘inputString’ i.e. the text that we pass inside the HTML text field as a task and then it creates several elements using DOM properties and appends their specific classes. After appending we insert all the elements inside the list as listItems.
Part 2: This addTask function is called when we click the button ‘addButton'(line 115) and then inside it we create a listItem with the value the user entered and then check the value, as it must not be an empty string then we simply add the above value inside the ‘inputTaskHolder’ and finally setting the value inside it as an empty string before calling the ‘bindFunction’.

Part 3: This code function is used to edit an existing task and we do so by keeping track of the parent node and then a simple if-else check whether the ‘editMode’ button is clicked or not if clicked then simply assign the value of the label innerText to value inside the editInput, if not then vice versa. Then after editing, we toggle the value of the ‘editMode’ as we have edited.

Part 4: In this part, we delete a task, and the way we do it is by making use of the parent node of the current node and then storing the parent of the parent node, and then simply deleting the child of this node.

Part 5: In this function, we mark the task as complete by simply appending the child of the parent node inside completeTaskHolder element and then calling the bindFunction.

Part 6:In this function, we mark the task as incomplete by simply appending the child of the parent node inside inCompleteTaskHolder element and then calling the bindFunction.

Part 7: In this part, we call the BindFunction where we respond to several user interaction activities and make several buttons work.

Part 8: In this final section, we iterate over several parts binding children with the help of for loop inside the incomplete and complete TaskHolder element.



Next Article
JavaScript Hello World
author
immukul
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • JavaScript-Course

Similar Reads

  • Introduction to JavaScript Course - Learn how to build a task tracker using JavaScript
    This is an introductory course about JavaScript that will help you learn about the basics of javascript, to begin with, the dynamic part of web development. You will learn the basics like understanding code structures, loops, objects, etc. What this course is about? In this course we will teach you
    4 min read
  • JavaScript Course What is JavaScript ?
    JavaScript is a very famous programming language that was originally started in the year of 1995 with the motive of making web pages alive. It is also an essential part of the web developer skillset. In simple terms, if you want to learn web development then learn HTML & CSS before starting JavaScri
    3 min read
  • JavaScript Hello World
    The JavaScript Hello World program is a simple tradition used by programmers to learn the new syntax of a programming language. It involves displaying the text "Hello, World!" on the screen. This basic exercise helps you understand how to output text and run simple scripts in a new programming envir
    2 min read
  • JavaScript Course Understanding Code Structure in JavaScript
    Inserting JavaScript into a webpage is much like inserting any other HTML content. The tags used to add JavaScript in HTML are <script> and </script>. The code surrounded by the <script> and </script> tags is called a script blog. The 'type' attribute was the most important a
    3 min read
  • JavaScript Course Variables in JavaScript
    Variables in JavaScript are containers that hold reusable data. It is the basic unit of storage in a program. The value stored in a variable can be changed during program execution. A variable is only a name given to a memory location, all the operations done on the variable effects that memory loca
    4 min read
  • JavaScript Data Types
    In JavaScript, each value has a data type, defining its nature (e.g., Number, String, Boolean) and operations. Data types are categorized into Primitive (e.g., String, Number) and Non-Primitive (e.g., Objects, Arrays). Primitive Data Type1. NumberThe Number data type in JavaScript includes both inte
    6 min read
  • JavaScript Course Operators in JavaScript
    An operator is capable of manipulating a certain value or operand. Operators are used to performing specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands. In JavaScript, operators are used for comparing values, performing arithm
    7 min read
  • JavaScript Course Interaction With User
    Javascript allows us the privilege to which we can interact with the user and respond accordingly. It includes several user-interface functions which help in the interaction. Let's take a look at them one by one. JavaScript Window alert() Method : It simply creates an alert box that may or may not h
    2 min read
  • JavaScript Course Logical Operators in JavaScript
    logical operator is mostly used to make decisions based on conditions specified for the statements. It can also be used to manipulate a boolean or set termination conditions for loops. There are three types of logical operators in Javascript: !(NOT): Converts operator to boolean and returns flipped
    3 min read
  • JavaScript Course Conditional Operator in JavaScript
    JavaScript Conditional Operators allow us to perform different types of actions according to different conditions. We make use of the 'if' statement. if(expression){ do this; } The above argument named 'expression' is basically a condition that we pass into the 'if' and if it returns 'true' then the
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences