So I have a textfield, a button for adding the text to localstorage and a button to remove it.
This is my script:
function save() {
var fieldValue = document.getElementById('textfield').value;
localStorage.setItem('text', fieldValue);
}
function load() {
var storedValue = localStorage.getItem('text');
if(storedValue) {
document.getElementById('textfield').value = storedValue;
}
}
function remove() {
document.getElementById('textfield').value = '';
localStorage.removeItem('text');
}
The save and load functions both work, but when I click the "remove button", it removes the button itself instead of the local storage value.