0

I am creating a basic todo - list and the input field seems to save all the data entered as a drop down list and I am unable to fix it.I have tried using the.reset() fn and also other options shown here like using val("") or val(0) and nothing seems to work.So can anyone suggest how I can fix this. I had tried the return fn and the val function as well but it still wouldn't work.Thanks in advance.



    const addForm = document.querySelector('.add');
    const todolst = document.querySelector('.todolst');
    const deletelst = document.querySelector('.delete')
    const task = addForm.add.value.trim();

    const newTemplate = task => {
      const html =
        <li class="list-group-item d-flex justify-content-between align-items-center"><span>${task}</span><i class="far fa-trash-alt delete"></i></li>
    todolst.innerHTML += html
    }
    // to add a tag
     addForm.addEventListener('Enter', e => {
     e.preventDefault();

      if (task.length) {

        newTemplate(task);

        addForm.val(0);
      }
    });
[enter image description here][1]


  [1]: https://i.stack.imgur.com/gIdeL.png
vardan
  • 1
  • 2

1 Answers1

0

Well, I managed to have found a solution which was by just clearing the cache on my browser. Although not the one I was expecting but seemed to have done the job. I tried the reset() and the clear() options which seemed have cleared the text just entered but not the previous ones that got stored onto the drop-down box.

vardan
  • 1
  • 2