#7.1 Adding ToDos

<!
DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="http://kyn1013.m/css/style.css"> <title>Hello from HTML!
</title> </head> <body> <form id="login-form" class="hidden"> <input required maxlength="15" type="text" placeholder="What is your name?" /> <button>Log In</button> </form> <h2 id="clock">00:00:00</h2> <h1 id="greeting" class="hidden"></h1> <form id="todo-form"> <input type="text" placeholder="Write a To Do and Press Enter" required/> </form> <ul id="todo-list"></ul> <div id="quote"> <span></span> <span></span> </div> <script src="js/clock.js"></script> <script src="js/greetings.js"></script> <script src="js/quotes.js"></script> <script src="js/background.js"></script> <script src="js/todo.js"></script> </body> </html>​
const toDoForm = document.getElementById("todo-form");
const toDoInput = toDoForm.querySelector("input"); //document.querySelector("#todo-form input");
const toDoList = document.getElementById("todo-list");

function paintToDo(newTodo){
    const li = document.createElement("li");
    const span = document.createElement("span");
    li.appendChild(span);
    span.innerText = newTodo;
    toDoList.appendChild(li);
}

function toDoSubmit(event){
    event.preventDefault();
    const newTodo = toDoInput.value;
    toDoInput.value = "";
    paintToDo(newTodo);
}

toDoForm.addEventListener("submit",toDoSubmit);