<input type="text" id="input_item" placeholder="Add a new item">
<button id="btnTask">Add</button>
</div>
<div>
<ul id="taskList"></ul>
</div>
</div>
<script>
var button = document.getElementById("btnTask")
var tasklist = document.getElementById("taskList")
button.onclick = function () {
if (input_item.value == "") {
alert("You must write something!")
} else {
var task = document.getElementById("input_item").value
var li = document.createElement("li")
var taskSpan = document.createElement("span")
taskSpan.innerHTML = task
li.appendChild(taskSpan)
var removeButton = document.createElement("button")
removeButton.innerHTML = "Remove"
removeButton.className = "btnRemove"
li.appendChild(removeButton)
tasklist.appendChild(li)
removeButton.onclick = function () {
tasklist.removeChild(li)
}
}
document.getElementById("input_item").value =""
}
</script>
</body>
</html>
Like this project
Posted Sep 11, 2024
Title: A clear and specific title for the list, such as "Daily Tasks," "Project X To-Do List," or "Grocery Shopping List."
Tasks: A list of individual items or