I am new to JavaScript and attempting to create a to-do list. How can I append an input with a checkbox attribute to my code so that paragraphs can be checked off once completed?
Here is my code below:
// ! DOM ELEMENTS
const taskInput = document.getElementById('taskInput');
const taskList = document.getElementById('taskList');
// ! ADD TASK
function addTask() {
if (taskInput.value === '') {
alert('Oh no... You have not written anything?');
} else {
let paragraph = document.createElement('p');
paragraph.textContent = taskInput.value;
taskList.appendChild(paragraph);
saveTasks();
}
taskInput.value = '';
}
<div class="container">
<h1>TO DO LIST</h1>
<input type="text" id="taskInput" placeholder="ENTER TASK HERE!">
<button id="addButton" click="addTask()">ADD</button>
<div id="taskList">
</div>
<p> lorem 10</p>
</div>