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:
Comments
Post a Comment