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

251
Views
Why isn't my localStorage showing the data in the container? It's showing my array in the console and I'm getting no error messages

I'm trying to keep the text entered in a tag and when I refresh it doesn't save and I can't figure out why. I'm not receiving any error in my localstorage, console, or VS.

I have localStorage being called first, and when I go into my console I see the information there.

// fill in and save timeslot items
var myTasks = [];
var nineOclock = document.getElementById("nineoclock");
// call function to get data

var savedTasks = function() {
    localStorage.getItem("myTasks")
    if (savedTasks) {
        savedTasks = JSON.parse(localStorage.getItem("myTasks"))
    } else {
        localStorage.getItem("myTasks", JSON.stringify(myTasks))
    };
};

function retrieveTasks() {
    if (savedTasks.length > 0) {
        savedTasks.forEach(task => {
            console.log("this task is: ", task);
            nineOclock.children[0].children[1].value = task.tasktxtarea
        })
    }
}
    

retrieveTasks();



var addTask = (event) =>{
    event.preventDefault();

    let task = {
        id: Date.now(),
        tasktxtarea: document.getElementById("tasktext").value, 
    }
    
    myTasks.push(task);

    console.log("added", myTasks)
    

    // save to local storage
    localStorage.setItem("myTasks", JSON.stringify(myTasks));
    

    if (moment().isAfter(date)) {
        $(task).addClass("list-group-item-danger");
    } else if (Math.abs(moment().diff(time, "days")) <= 2) {
        $(task).addClass("list-group-item-warning");
    }
         
}
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!