Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */
- var list = document.getElementById('list'); //The unordered list.
- var entry = document.createElement("li"); //Whatever this is. I'm assuming a command saved into a variable (?).
- //var todolist = list.getElementsById('li');
- // var btn = document.getElementById('ToDoButton');
- //
- // btn.addEventListener("click", function(){
- // todolist.appendChild('li');
- // });
- /* Upon submission of the item in the text field, the string is stored in inputValue
- and theText becomes a text node of inputValue, which is appended to the end of the variable
- entry. This means that there should be a new item added to the unordered list with the information
- found in the text field, but it doesn't show.
- Also, as far as I know, this is only if the Add button is clicked, and not upon
- pressing Enter while in the text box. */
- function newElement() {
- var inputValue = document.getElementById("textBox").value;
- var theText = document.createTextNode(inputValue);
- entry.appendChild(theText);
- if (inputValue !== '') {
- document.getElementById(list).appendChild(entry);
- }
- }
Add Comment
Please, Sign In to add comment