javascript - Why is my localStorage code not working? -


i'm trying make div div disappear , stay gone when user comes back. doesn't seem want. when press button, nothing happens. not value of localstorage changes...

localstorage.done = localstorage.done || false; $('#mybutton').addeventlistener('click', function() {     if (!localstorage.done) {         localstorage.done = true;         $('#mydiv').style.display = "none";      } }); 

you code localstorage working (even if suggested use getter/setter methods instead of direct property access).

your problem this:

$('#mybutton').addeventlistener('click', function() { 

jquery not know .addeventlistener want call .bind()

    localstorage.done = localstorage.done || false;     $('#mybutton').bind('click', function() {         if (!localstorage.done) {             localstorage.done = true;             $('#mydiv').hide();         }     }); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -