, (imo) + ( ). . , , ( , , , ).
.
/ . cookie ( , - , -, cookie - , t ).
, jQuery Cookie Plugin, ( ) . , , , cookie . , , , (- cookie). cookie , , .
<div id="ShowHideContainer">
<p><a id="ShowHideButton">Click Here To Hide!</a></p>
<div id="ShowHideBox">text that gets shown and hidden, woo</div>
</div>
<script>
$(document).ready(function()
{
var $ShowHideBox = $('#ShowHideBox').hide(),
$ShowHideButton = $('#ShowHideButton');
initBox();
$('#ShowHideButton').click(function() {
if (boxVisible())
{
hideBox();
}
else
{
showBox();
}
});
function initBox()
{
if ( $.cookie('BoxVisible') && ! boxVisible() )
{
showBox();
}
else if ( ! $.cookie('BoxVisible') && boxVisible() )
{
hideBox();
}
}
function boxVisible()
{
return $ShowHideBox.hasClass('hidden')? false : true;
}
function showBox()
{
$ShowHideBox.slideUp(250).removeClass('hidden');
$ShowHideButton.html("Click Here to Hide!");
$.cookie('BoxVisible', 1, {expires: 365});
}
function hideBox()
{
$ShowHideBox.slideDown(250).addClass('hidden');
$ShowHideButton.html("Click Here to Show!");
$.cookie('BoxVisible', 0, {expires: 365});
}
});
</script>