multi localstorage
Wie man mehere Wete in Localstorage speichern kann
Der hier verwendete Code
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>multi localstorage</title>
</head>
<body>
<style>
textarea{
width: 100%;
height:8vh;
padding: 10px
}
#save{
margin-top:29px;
}
</style>
<textarea placeholder="Testfeld 1"></textarea>
<textarea placeholder="Testfeld 2"></textarea>
<textarea placeholder="Testfeld 3"></textarea>
<textarea placeholder="Testfeld 4"></textarea>
<textarea placeholder="Testfeld 5"></textarea>
<button id="save"> Cache-Save </button>
<script>
var input_textarea = document.querySelectorAll('textarea');
var save_button = document.getElementById('save');
save_button.addEventListener('click',function(){
input_textarea.forEach(function(g,ix){
localStorage.setItem('content'+ix, g.value);
})
//holen();
})
function holen() {
input_textarea.forEach(function(g,ix){
g.value=localStorage.getItem('content'+ix);
})
}
holen();
</script>
</body>
</html>