I’m trying to make a div div disappear and stay gone even when the user comes back. It doesn’t seem to do what I want. When I press the button, nothing happens. Not even the value of the localStorage changes…
localStorage.done = localStorage.done || false;
$('#myButton').addEventListener('click', function() {
if (!localStorage.done) {
localStorage.done = true;
$('#myDiv').style.display = "none";
}
});
You code for the
localStorageis actually working (even if its suggested to use its getter/setter methods instead of direct property access).Your problem is this:
jQuery does not know about
.addEventListeneryou want just to call.bind()