I am new to creating a to-do app and need some guidance. When a user enters a task, I successfully create a list item for that task. However, I am unsure how to add a delete icon next to the newly created li element. Can someone please help me out? Below is my current code:
const inputArea = document.querySelector('#input');
const allTasks = document.querySelector('#list');
const deleteTask = document.querySelector('#close');
function collectInfo() {
if (inputArea.value === '') {
alert('Please enter a task to add!');
} else if (inputArea.value != '') {
const node = document.createElement('li');
const newTask = allTasks.appendChild(node);
newTask.textContent = inputArea.value;
}
}
const clicked = document.querySelector('#add');
clicked.addEventListener('click', collectInfo);