Skip to content

Instantly share code, notes, and snippets.

@dce
Created May 6, 2010 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dce/f343541bc67eef9b2502 to your computer and use it in GitHub Desktop.
Save dce/f343541bc67eef9b2502 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1.4.2");</script>
<script>
$(document).ready(function() {
var $list = $("#items li");
var loadItems = function() {
$.each(localStorage['items'].split('\n'), function() {
$list.append("<li>" + this + "</li>");
});
}
if (localStorage['items']) {
loadItems();
} else {
localStorage['items'] = "";
}
$("#new-todo").submit(function() {
localStorage['items'] += "\n" + $("#new-todo-text").val();
return false;
});
});
</script>
</head>
<body>
<h1>HTML5 Test</h1>
<ul id="items">
<li>WHOA</li>
</ul>
<form id="new-todo">
<input type=text id="new-todo-text" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment