html5 local storage

example about HTML5 Local Storage

http://jsbin.com/iqura/edit#javascript,html


jQuery(function($){

	var edit = $('.edit');

	edit.blur(function() {

		localStorage.setItem('todoData', this.innerHTML);

	});

	if ( localStorage.getItem('todaData') ) {

		edit.innerHTML = localStorage.getItem('todoData');

	}

});

html:


<!doctype html>

<html>

<head>

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

	<script src="script.js"></script>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<title>title</title>

</head>

<body>

<section>

	<ul class="edit" contenteditable="true">

		<li>Sample data</li>

	</ul>

</section>

</body>

</html>  

Leave a Comment