I'm trying to build a to-do list application with Javascript. But I have a question about creating a new element.
function todoList() {
var item = document.getElementById("todoInput").value
var text = document.createTextNode(item)
var newItem = document.createElement("li")
newItem.appendChild(text)
document.getElementById("list").appendChild(newItem)
}
It's my javascript code. It's working, I can create a li from an input value. But I want to include a delete icon all li items. like this:
<ul id="list">
<li>New item <i class="fa fa-trash-o de"></i> </li>
</ul>
Thanks.