Last active
September 28, 2021 10:15
-
-
Save anak10thn/4423940 to your computer and use it in GitHub Desktop.
web storage html5 with jquery
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
<!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