Skip to content

Instantly share code, notes, and snippets.

@anak10thn
Last active September 28, 2021 10:15
Show Gist options
  • Save anak10thn/4423940 to your computer and use it in GitHub Desktop.
Save anak10thn/4423940 to your computer and use it in GitHub Desktop.
web storage html5 with jquery
<!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
if(!$('.ta').val()){
var localStorage = window.localStorage.getItem('value');
$('.ta').val(localStorage);
$('.tx').text(localStorage);
}
$('.ta').keyup(function(){
var value = $(this).val();
$('.tx').text(value);
window.localStorage.setItem('value',value);
});
})
</script>
</head>
<body>
<textarea class="ta"></textarea><br>
Stored :<b><div class="tx"></div></b>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment