This is my second query and I'm hoping it covers everything. My knowledge of javascript is limited, which has made it difficult for me to get my code working properly. Despite trying various different approaches, I have been unable to resolve the issue. The sections enclosed in brackets represent what I am aiming for but have not managed to implement successfully. To summarize:
- when button 1 is clicked: set localStorage.thing1 to 0
- when button 2 is clicked: set localStorage.thing1 to 1
- if localStorage.thing1 is equal to 0, hide thingtext1; otherwise, display thingtext1
<!DOCTYPE html>
<html>
<body>
<p id="thingtext1">Here Is Some Text</p>
<button id="thing1" onclick="(set value of thing1 as 0 in localStorage)">Hide</button>
<button id="thing1" onclick="(set value of thing1 as 1 in localStorage)">Show</button>
<script>
(ONLOAD)
if (localStorage.getItem("thing1") === "0") {
(HIDE(#thingtext1))
}
else{
if (localStorage.getItem("thing1") === "1"){
(SHOW(#thingtext1))
}
}
(SET thing1 into localStorage)
</script>
</body>
</html>
Your assistance in resolving this matter would be greatly appreciated. Thank you.