javascript - Show / hide divs between 2 divs between two pages -


i have 6 divs, 2 have contents in them , either hidden or visible depending on of 2 'hide' , 2'show' divs clicked, please @ fiddle see mean.

jsfiddle

page1.html

<div id="show-politics" class="topics">show</div> <div id="show-technology" class="topics">show</div> 

page2.html

<div id="hide-politics" class="topics">hide</div> <div id="rss-feeds" class="me">contents</div>  <div id="hide-technology" class="topics">hide</div> <div id="rss-feeds2" class="me">contents</div> 

js

    $(document).ready(function($){      if (modernizr.localstorage) {        $('#hide-politics').click(function(e){        localstorage.setitem('subscribed',true);         $('#rss-feeds,#hide-politics').hide();         $('#hide-politics').hide();         $('#show-politics').show();      });        $('#show-politics').click(function(e){       localstorage.setitem('subscribed',true);       localstorage.clear();       $('#rss-feeds,#hide-politics').show();       $('#show-politics').hide();     });        var is_subscribed = localstorage.getitem('subscribed');        if(is_subscribed){     console.log('localstorage');     $('#rss-feeds,#hide-politics').hide();   }    if(!is_subscribed){     console.log('no localstorage');     $('#rss-feeds').show();     $('#show-politics').hide();   }  }   });  $(document).ready(function($){  if (modernizr.localstorage) {    $('#hide-technology').click(function(e){     localstorage.setitem('subscribed2',true);       $('#rss-feeds2,#hide-technology').hide();       $('#hide-technology').hide();       $('#show-technology').show();   });    $('#show-technology').click(function(e){       localstorage.setitem('subscribed2',true);       localstorage.clear();       $('#rss-feeds2,#hide-technology').show();       $('#show-technology').hide();   });    var is_subscribed2 = localstorage.getitem('subscribed2');    if(is_subscribed2){     console.log('localstorage');     $('#rss-feeds2,#hide-technology').hide();   }    if(!is_subscribed2){     console.log('no localstorage');     $('#rss-feeds2').show();     $('#show-technology').hide();   }  }   }); 

i need 'show' divs on page 'hide' divs , contents divs, on same page, works extent, problem that, cannot make 1 div visible when 'show' divs on page, when click 1 'show' div, hidden divs become visible instead of one, when on same page, behave way supposed to, in fiddle,

can take @ code , see if there way can make behave same way in fiddle when on separate pages?

it uses modenizr local storage


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -