javascript - Show hidden div in page after clicking link to open the page -


i have html page in hidden div becomes visible when button clicked. this:

$('#display').click(function(){     $('#itemlist').removeclass('hide');     ... }) 

on page, there link when clicked takes user earlier page, , element id='itemlist' on page has become visible. code this:

<a href='firsthtml.php'> view items</a> 

i not sure else add code make other page appear hidden element visible. can please?

one of probable solution localstorage .where may implement cookies or string query pass value other page.

i showing use of localstorage , may store id in localstorage on click of anchor below

<a href='firsthtml.php' data-showid='itemlist'> view items</a> 

now bind event on anchor

$("[data-showid]").bind('click',function(){     var idtoshow=$(this).attr('data-showid');     if(idtoshow)       store('visibleid', idtoshow); }); 

now need define these functions .

   function setup() {         var tmp = get('visibleid');         if (tmp)           showdiv(tmp);     }      function showdiv(cls) {         $("#"+cls).removeclass('hide');     }     function get(name) {         if (typeof (storage) !== "undefined") {           return localstorage.getitem(name);         } else {           window.alert('please use modern browser view template!');         }     }     function store(name, val) {         if (typeof (storage) !== "undefined") {           localstorage.setitem(name, val);         } else {           window.alert('please use modern browser view template!');         }     } 

now call setup() on dom ready..


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -