I am wondering if it is possible to ensure that when the page is loaded, the block was already closed if it was hidden before.
That is, I have a block:
<div class="sliderBlock"> <div>....some info....</div> </div><!-- .sliderBlock --> In this block there is a button that can collapse and expand it to a certain size. Namely, an open block : 350 px , a collapsed block: 50 px ;
Suppose I opened the main page and hid this block. How can I make it so that when switching to other pages, this slider is still minimized without any actions visible to the user?
I tried to do the following:
$(document).ready(function(){ var storage = $.localStorage; if (storage.get('_slider') == 'hide') { sliderBlock.css({'height': '50px'}); hideSlider.css({'transform': 'rotate(-45deg)'}) } }); Used local storage for verification. The _slider value can be empty or take the show value, it means that the block is open, or accept the value of hide - the block is closed.
When it all worked without visible action. But now for some reason it loads the page, and the block of full size is rolled up to 50 px.
Can someone advise how to solve this problem?