1

I'm trying to run my code for my To do list project but keep getting the error (cannot read appendChild).

 let addToDoButton = document.getElementById('addToDo'); let toDoContianer = document.getElementById('toDoContianer'); let inputField = document.getElementById('inputField'); addToDoButton.addEventListener('click', function() { var paragraph = document.createElement('p'); paragraph.classList.add('paragraph-styling'); paragraph.innerText = inputField.value; toDoContianer.appendChild(paragraph); inputField.value = ""; paragraph.addEventListener('click', function() { paragraph.style.textDecoration = 'line-through'; }); paragraph.addEventListener('dblClick', function() { toDoContianer.removeChild(paragraph); }); }); 
4
  • 1
    does it solve your question? stackoverflow.com/questions/30014090/… Commented Nov 5, 2021 at 6:45
  • check the value of toDoContianer, console.log(toDoContianer); Commented Nov 5, 2021 at 6:59
  • Error is saying it does not have an element in toDoContianer. So you need to figure out why it did not find the element. Commented Nov 5, 2021 at 14:26
  • My guess is toDoContianer is spelled wrong here and is correct in your HTML. Commented Nov 5, 2021 at 14:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.