Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
How to make list stay on page after browser refreshed?

I am trying to make the list stay on the page when the browser refreshes, I did ask this question before, but I am a bit confused about what exactly should I do or how should I update my code to get it right.

Here is a link to my original question original question

They mentioned a forEach loop should be used, which I have been trying but it is not working

//variable of empty array that gets new task
let taskList = [];

//function that creates new tasks with date and time

const creatTask = (task) => {
  
  const data = {
   id: createId(),
  taskNew: el.input.value,
  taskDate:el.date.value,
   taskTime: el.time.value,
}

  if (!data.taskNew) {
    alert("Please add a new Task");
  }
  if (!data.taskDate) {
    alert("Please add a new Task with a due date");
  }
  if (!data.taskTime) {
    alert("Please add a new Task with a due time");
  }

    const tasks = document.createElement("div");

    tasks.innerHTML = `
       <div class="task-content">
        <div class="task" data-id="${data.id}">
        <div class="new-task-created">${data.taskNew}</div>
        <label class="due-date">${data.taskDate}</label>
        <label class="due-time">${data.taskTime}</label>
    </div>

    <div class="atcion-buttons">
        <button onclick="editItem()" class="edit" data-id="${data.id}">Edit</button>
        <button onclick="deleteItem()" class="delete" data-id="${data.id}">Delete</button>
        <button onclick="completeItem()" class="complete" data-id="${data.id}">Complete</button>
    </div>
</div>`;


  taskList.push(data);
  el.list.appendChild(tasks);
  storeList();
};

//function that stores task list.
function storeList() {

  localStorage.setItem(STORAGE_KEY, JSON.stringify(taskList));
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!