Created
April 7, 2019 04:01
-
-
Save lamecksilva/49b5858cf535cd4b02fb51d5504ad79d to your computer and use it in GitHub Desktop.
Primeira versão do script para o localstorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function addItem() { | |
// Pegando os valores dos campos name e qtd | |
const name = $('input[name=name]').val(); | |
const qtd = $('input[name=qtd]').val(); | |
// Criando uma string com o objeto a ser adicionado no localstorage | |
const dataObj = JSON.stringify({ name, qtd }); | |
localStorage.setItem('item', dataObj); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment