asp.net - How to prevent jQuery from reloading on page refresh -


i'm showing hidden textboxes using jquery so:

      $("#showtextbox").click(function () {       $("#textbox").fadein("slow");       }); 

this works fine, once page refreshed, texbox hidden again. there way work around textbox doesn't hide after page refresh? once textbox made visible, don't want hidden again. i'm working asp.net.

you can store variable in localstorage/a cookie , refer that, e.g.:

var $textbox = $("#textbox");  if (localstorage.getitem('clicked')) {      $textbox.show(); } else {     $("#showtextbox").click(function () {         $textbox.fadein("slow");         localstorage.setitem('clicked', true);     }); } 

just aware you'll need polyfill older browsers if using localstorage:

https://github.com/modernizr/modernizr/wiki/html5-cross-browser-polyfills#web-storage-localstorage-and-sessionstorage


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -