javascript - accessing local variable on global scope -


i have following code, tells when submit button pressed, hide filterlist , add variable in localstorage refering closeded filterlist , submit form in end. logic happen if browser window size less 768px (mobile size)

if ($(window).width() < 768) {     var $target, $form, $filterlist;     $(".f-f .f-ft [type='submit']").on("click", function(event) {         event.preventdefault();         $target = $(event.currenttarget);         $form = $($target.parents("form")[0]);         $filterlist = $form.find(".f-inp");          $filterlist.hide();         localstorage.setitem("filterlist", "closed");         $form.submit();     });     localstorage.getitem("filterlist") === "closed" ? $filterlist.hide() : $filterlist.show(); } else {     $(".filter").on("click", function(event) {         var $target = $(event.currenttarget),             $form = $($target.parents("form")[0]);          $form.submit();     }); } 

my question how access variable $filterlist new value outside (on click) method? there other ways using localstorage?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -