first of all, super beginner here. I’m trying to do a to do list. The add part works fine, it looks like this:
HTML:
<input type="text" id="input">
<div class="container">
<button id="salvar">Save</button>
<button id="remover">Remove</button>
</div>
<table id="todoitems">
<tr>
<th>Tarefa</th>
</tr>
</table>
And here’s the JS:
let salvar = document.getElementById("salvar")
let remove = document.getElementById("remover")
salvar.onclick = saveitem
function saveitem(){
let item = document.getElementById("input").value
let novoitem = document.createElement("tr")
let lista = document.getElementById("todoitems")
novoitem.innerText = item
lista.appendChild(novoitem)
}
How can i create a function that removes the last added item?