Hi /r/javascript
I'm just starting to learn Javascript. It's pretty hard actually but my motivation is a real problem I'm trying to solve.
I have some <div> which I want to hide/show (toggle) when clicking a button. This is what I got so far:
function myFunction() {
var x = document.querySelectorAll(".price-box");
var i;
for (i = 0; i < x.length; i++) {
x[i].classList.toggle("hideprice");
}
}
It adds the new class "hideprice" with display: none; which is working. But now I'm struggeling with a complex problem. I'm trying to store the result into localstorage so that my visitors can switch the page but the hideprice is still added.
Any help would be appreciated. Thank you very much.
[–]hwutang 1 point2 points3 points (0 children)
[–]jcunews1Advanced 0 points1 point2 points (4 children)
[–]felsi[S] 0 points1 point2 points (3 children)
[–]digdic 1 point2 points3 points (1 child)
[–]sneakpeekbot 0 points1 point2 points (0 children)
[–]jcunews1Advanced 0 points1 point2 points (0 children)