javascript - Toggling menu and click counter reset -


i started learn js , jquery, , i'm trying achieve toggling menu resets clicks counter on other menu when being opened.

and here js code

// javascript document       var toggleclicks = $('.toggle').data('clicks');        var menuclicks = $('.toggle-menu').data('clicks');     $(document).ready(function() {   //wrapper//     $('.toggle').click(function() {       ++toggleclicks;       if (toggleclicks%2 === 0) {          // clicks          $('.wrapper').css({'margin-top': '-260px'});          $('.icon-menu, .icon-bell').css({'color': '#ababab'});          $('.toggle-menu').data('clicks',0)       } else {          // odd clicks          $('.wrapper').css({'margin-top': '0'});          $('.icon-bell').css({'color': 'red'});          $('.contact, .diet, .hours, .classes, .gym').css({'margin-bottom': '-300px'});          $('.main-nav').css({'width': '0'});          $('.icon-menu').css({'color': '#ababab'});       }     });  //nav bar//     $('.toggle-menu').click(function() {       ++menuclicks;         if (menuclicks%2 === 0) {          // clicks          $('.main-nav').css({'width': '0'});          $('.icon-menu, .icon-bell').css({'color': '#ababab'});          $('.toggle').data('clicks',0)       } else {          // odd clicks          $('.main-nav').css({'width': '50%'});          $('.icon-menu').css({'color': 'red'});          $('.icon-bell').css({'color': '#ababab'});          $('.wrapper').css({'margin-top': '-260px'});          $('.contact, .diet, .hours, .classes, .gym').css({'margin-bottom': '-300px'});       }     }); 

** as can see, toggle won't work. suggestions?**

thanks!

enter code here

as can see image, when use === , type of condition matters.

=== matches exact type of both values.

so in case, storing numeric in data-clicks trying access '0' string. it's not matching.

instead can use == match both


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -