Skip to content

Instantly share code, notes, and snippets.

@sergey-shambir
Created July 5, 2019 04:05
Show Gist options
  • Save sergey-shambir/0de74fee9fa8b4972590c89df34174e3 to your computer and use it in GitHub Desktop.
Save sergey-shambir/0de74fee9fa8b4972590c89df34174e3 to your computer and use it in GitHub Desktop.
To-Do App JS, layer 4
function onPageLoaded() {
const saveButton = document.querySelector("button.save");
const clearButton = document.querySelector("button.clear");
const showTipsButton = document.querySelector("button.showTips");
const closeTipsButton = document.querySelector("a.closeTips");
const overlay = document.querySelector("#overlay");
// ..
saveButton.addEventListener("click", () => {
localStorage.setItem("todos", ul.innerHTML);
});
clearButton.addEventListener("click", () => {
ul.innerHTML = "";
localStorage.removeItem('todos', ul.innerHTML);
});
showTipsButton.addEventListener("click", () => {
overlay.style.height = "100%";
});
closeTipsButton.addEventListener("click", () => {
overlay.style.height = "0";
});
}
document.addEventListener("DOMContentLoaded", onPageLoaded);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment