I am making a to-do list. I am trying to add two buttons (checked and delete). When I click on the delete button I want to delete the entire list. For example:
| Grocery shopping| (Checked button) (delete button) |
When I click on the delete button it should delete the whole list as in here (grocery shopping)
But, I am using bootstrap here with javascript and when I refer to className remove here it doesn't actually delete anything and I assume it's not actually referring to the className remove since my className is remove btn btn-primary font-weight-bold float-right mt--5 since I am using bootstrap, Can anyone tell me what am I doing wrong?
My code:
const todoInput = document.querySelector(".form-control");
const todoButton = document.querySelector(".add");
const todoList = document.querySelector(".todo-list");
todoButton.addEventListener("click", addTodo);
todoList.addEventListener("click", deleteCheck);
function addTodo(event) {
  event.preventDefault();
  const todoDiv = document.createElement("div");
  todoDiv.classList.add("todo-item");
  const newTodo = document.createElement("h6");
  newTodo.innerText = todoInput.value;
  todoDiv.appendChild(newTodo);
  const removeButton = document.createElement("button");
  removeButton.className =
    "remove btn btn-primary font-weight-bold float-right mt--5";
  const spancontainerforremove = document.createElement("span");
  const icontainerforremove = document.createElement("i");
  icontainerforremove.className = "fas fa-trash-alt";
  spancontainerforremove.appendChild(icontainerforremove);
  removeButton.appendChild(spancontainerforremove);
  todoDiv.appendChild(removeButton);
  const completedButton = document.createElement("button");
  completedButton.className =
    "complete btn btn-primary font-weight-bold float-right mr-1 mt--5";
  const spancontainer = document.createElement("span");
  const icontainer = document.createElement("i");
  icontainer.className = "fas fa-check-circle";
  spancontainer.appendChild(icontainer);
  completedButton.appendChild(spancontainer);
  todoDiv.appendChild(completedButton);
  todoList.appendChild(todoDiv);
  todoInput.value = "";
}
function deleteCheck(e) {
  const item = e.target;
  console.log(item.className);
  if (item.className === "remove") { //does not work
    item.remove();
  }
}
 
    