Advertisement
dronkowitz

JavaScript (Creating Website Code)

Jan 13th, 2023
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const inputField = document.getElementById("input_field");
  2. const addButton = document.getElementById("button");
  3. const toDoList = document.getElementById("todolist");
  4.  
  5. addButton.addEventListener("click", () => {
  6.  
  7.     const inputValue = inputField.value;
  8.     const newListItem = document.createElement("li");
  9.     const checkBox = document.createElement("input");
  10.     checkBox.type = "checkbox";
  11.     const label = document.createElement("label");
  12.     label.textContent = inputValue;
  13.     newListItem.appendChild(checkBox);
  14.     newListItem.appendChild(label);
  15.     toDoList.appendChild(newListItem);
  16.     inputField.value = '';
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement