javascript - On toggle Hide/show -
i have code. if user press on lets burger
, add session
basket. reload of page doesn't open current window view(toggle)
how can make open current again on reload...
<script type="text/javascript"> function unhide(divid) { var item = document.getelementbyid(divid); if (item) { item.classname=(item.classname=='hidden')?'unhidden':'hidden'; } } </script>
this how show/hide text.
<a href="javascript:unhide('sandwich');"></a> <div id="sandwich" class="hidden"> here go 1 </div> <a href="javascript:unhide('burger');"></a> <div id="burger" class="hidden"> here go 2 </div>
things not persistent across page reload / refresh.
there 2 basic approaches it:
- session cookie , session on server, communication via ajax
- store in cookie
both require work, it's unavoidable.
for cookie part, there's nice jquery plugin called jquery.cookie
.
Comments
Post a Comment