Created
May 21, 2020 06:30
-
-
Save kelvin8773/8019daeef44c3b3f7d4e3b05213bf115 to your computer and use it in GitHub Desktop.
mymemo-web - JS-Test
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
// TODO: add memo item | |
function $(id) { | |
return document.getElementById(id); | |
} | |
function renderMemo() { | |
const memos = JSON.parse(window.localStorage.getItem('memoItems')); | |
const memoLists = $('memo-items-list'); | |
const memoItem = document.createElement('div'); | |
memos.forEach(memo => { | |
memoItem.innerText = memo | |
memoLists.appendChild(memoItem); | |
}) | |
} | |
$('memo-textbox').addEventListener('keypress', (e) => { | |
if (e.key === 'Enter') { | |
const data = e.target.value; | |
window.localStorage.setItem('memoItems', JSON.stringify(data)); | |
renderMemo(); | |
} | |
}); |
Author
kelvin8773
commented
May 21, 2020
This is the working version, - about 30 mins late.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment