Jquery cookie on toggle view
I have a jquery toggle that swap between two layouts. I need to set a cookie so it dosen't reset every time the browser is refreshed. How can I implent this in this script:
<script type="text/javascript">
$(document).ready(function(){
$("a.switch_thumb").toggle(function(){
$(this).addClass("swap");
$("ul.display").fadeOut("fast", function() {
$(开发者_Python百科this).fadeIn("fast").addClass("thumb_view");
});
}, function () {
$(this).removeClass("swap");
$("ul.display").fadeOut("fast", function() {
$(this).fadeIn("fast").removeClass("thumb_view");
});
});
});
You can use a jQuery cookie plugin such as http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/ and set it whenever you perform the toggle. Then on page load you can check the value and show/hide whatever portions of the screen you would like.
精彩评论