Created
February 24, 2014 23:57
-
-
Save slopeofhope81/9199861 to your computer and use it in GitHub Desktop.
todo app using local storage
This file contains hidden or 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
$(function(){ | |
$("#add").click(function(){ | |
var description=$("#description").val(); | |
if(description === ""){ | |
$("#alert").html("<strong>Warning</strong> You left the todo app!"); | |
$("#alert").fadeIn().delay(1000).fadeOut(); | |
return false; | |
} | |
$("#todos").prepend("<li><input type='checkbox' name='checkbox'>"+ description+ "</li>"); | |
$("#form")[0].reset(); | |
var todos = $("#todos").html(); | |
localStorage.setItem("todos", todos); | |
return false; | |
}) | |
if (window.localStorage.getItem("todos")){ | |
$("#todos").html(localStorage.getItem("todos")); | |
return false; | |
} | |
$("#clear").click(function(){ | |
window.localStorage.clear(); | |
location.reload(); | |
return false; | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment