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

255
Views
How to create an object of an <li> element?

I created a To-Do List with JS. I'm mostly finished but my last task is to create a local storage. The purpose of that is, that the Tasks should not vanish, when I reload the page. I know that I have to create an array of objects for that, but I don't know how to represent my <'li'> element as an object. So how do I represent my Tasks as an object to create an array

add.addEventListener("click", function (){

    // create task text
    if(task.value != ""){
    let li = document.createElement('li');
    ul.appendChild(li);

        // create checkbox
        let box = document.createElement('input');
        box.setAttribute('type', 'checkbox');
        li.appendChild(box);
        box.classList.add('check');

    //create span
        let span = document.createElement('span');
        li.appendChild(span);
        span.innerHTML= task.value;
        span.classList.add('task');


    // create delete button
    let btn = document.createElement('button');
    li.appendChild(btn);
    btn.classList.add("delete-btn");
    btn.innerHTML = 'x';
    btn.onclick = function () {
        btn.parentElement.remove();
    };
});
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!