I'm following a tutorial online on how to make a to do list. found here
I've following it perfectly, but it won't work. Browser states the 'appendChild' is null. The tutorial is 2 years old, is it just script that has been outdated?
Really appreciate the help
function addNewItem() {
var listItem = document.createElement("li");
listItem.innerText = "Hello";
list.appendChild(listItem);
}
var btnNew = document.getElementById("btnAdd");
btnNew.onclick = function() {
addNewItem(document.getElementById("todoList"));
};
and here's the related part of the html
<p><button id="btnAdd">New Item</button></p>
<ul id="todolist">
</ul>
<script src="todo.js"></script>
listdefined?