Skip to content

Instantly share code, notes, and snippets.

@brunokunace
Created November 10, 2021 21:44
Show Gist options
  • Save brunokunace/9d5d39e9c2258d97f7189760cda13e95 to your computer and use it in GitHub Desktop.
Save brunokunace/9d5d39e9c2258d97f7189760cda13e95 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
<input type="text" id="nomeCliente">
<button type="button" onclick="adicionar()">adicionar clientes</button>
<h3>Lista de clientes</h3>
<ol id="listaClientes">
</ol>
<script>
function adicionar() {
const inputName = document.getElementById('nomeCliente').value
adicionarNaLista(inputName)
}
function adicionarNaLista (nome) {
const lista = document.getElementById('listaClientes')
const cliente = document.createElement('li')
cliente.appendChild(document.createTextNode(nome))
lista.appendChild(cliente);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment