Guest User

todo.js

a guest
Mar 4th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*  */
  2.  
  3.  
  4. var list = document.getElementById('list'); //The unordered list.
  5. var entry = document.createElement("li"); //Whatever this is. I'm assuming a command saved into a variable (?).
  6.  
  7. //var todolist = list.getElementsById('li');
  8. // var btn = document.getElementById('ToDoButton');
  9. //
  10. // btn.addEventListener("click", function(){
  11. //     todolist.appendChild('li');
  12. // });
  13.  
  14. /* Upon submission of the item in the text field, the string is stored in inputValue
  15. and theText becomes a text node of inputValue, which is appended to the end of the variable
  16. entry. This means that there should be a new item added to the unordered list with the information
  17. found in the text field, but it doesn't show.
  18.  
  19. Also, as far as I know, this is only if the Add button is clicked, and not upon
  20. pressing Enter while in the text box. */
  21. function newElement() {
  22.     var inputValue = document.getElementById("textBox").value;
  23.     var theText = document.createTextNode(inputValue);
  24.     entry.appendChild(theText);
  25.     if (inputValue !== '') {
  26.         document.getElementById(list).appendChild(entry);
  27.     }
  28. }
Add Comment
Please, Sign In to add comment